Permalink
Cannot retrieve contributors at this time
55 lines (47 sloc)
1.59 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
docker-qemu-action/src/main.ts
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as context from './context'; | |
import * as core from '@actions/core'; | |
import * as exec from '@actions/exec'; | |
interface Platforms { | |
supported: string[]; | |
available: string[]; | |
} | |
async function run(): Promise<void> { | |
try { | |
const input: context.Inputs = context.getInputs(); | |
await core.group(`Docker info`, async () => { | |
await exec.exec('docker', ['version'], { | |
failOnStdErr: false | |
}); | |
await exec.exec('docker', ['info'], { | |
failOnStdErr: false | |
}); | |
}); | |
await core.group(`Pulling binfmt Docker image`, async () => { | |
await exec.exec('docker', ['pull', input.image]); | |
}); | |
await core.group(`Image info`, async () => { | |
await exec.exec('docker', ['image', 'inspect', input.image]); | |
}); | |
await core.group(`Installing QEMU static binaries`, async () => { | |
await exec.exec('docker', ['run', '--rm', '--privileged', input.image, '--install', input.platforms]); | |
}); | |
await core.group(`Extracting available platforms`, async () => { | |
await exec | |
.getExecOutput('docker', ['run', '--rm', '--privileged', input.image], { | |
ignoreReturnCode: true, | |
silent: true | |
}) | |
.then(res => { | |
if (res.stderr.length > 0 && res.exitCode != 0) { | |
throw new Error(res.stderr.trim()); | |
} | |
const platforms: Platforms = JSON.parse(res.stdout.trim()); | |
core.info(`${platforms.supported.join(',')}`); | |
context.setOutput('platforms', platforms.supported.join(',')); | |
}); | |
}); | |
} catch (error) { | |
core.setFailed(error.message); | |
} | |
} | |
run(); |