mirror of
https://github.com/docker/setup-qemu-action.git
synced 2025-06-13 14:47:14 +02:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
e81a89b173 | |||
2d3efc7878 | |||
bfc44eaf57 | |||
25725d8d2e | |||
8c1e35a8c6 | |||
f3c51a3313 | |||
c47ad32952 | |||
aa087459ac | |||
9443994984 | |||
81a47e15eb | |||
c5ffa2a617 | |||
b98716c80f | |||
a79c9a847e | |||
4620c11b70 | |||
359ac4c862 | |||
d7a4485e0c | |||
0522dcd2bf | |||
d8ca9c3fab |
2
.github/workflows/validate.yml
vendored
2
.github/workflows/validate.yml
vendored
@ -19,6 +19,6 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Validate
|
||||
uses: docker/bake-action@v1
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
targets: validate
|
||||
|
30
README.md
30
README.md
@ -13,7 +13,8 @@ ___
|
||||
* [Usage](#usage)
|
||||
* [Customizing](#customizing)
|
||||
* [inputs](#inputs)
|
||||
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
|
||||
* [outputs](#outputs)
|
||||
* [Contributing](#contributing)
|
||||
|
||||
## Usage
|
||||
|
||||
@ -29,7 +30,7 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
```
|
||||
|
||||
## Customizing
|
||||
@ -38,10 +39,10 @@ jobs:
|
||||
|
||||
Following inputs can be used as `step.with` keys
|
||||
|
||||
| Name | Type | Description |
|
||||
|------------------|---------|------------------------------------|
|
||||
| `image` | String | QEMU static binaries Docker image (default [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags)) |
|
||||
| `platforms` | String | Platforms to install (e.g. `arm64,riscv64,arm` ; default `all`) |
|
||||
| Name | Type | Description |
|
||||
|-------------|--------|---------------------------------------------------------------------------------------------------------------------------|
|
||||
| `image` | String | QEMU static binaries Docker image (default [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags)) |
|
||||
| `platforms` | String | Platforms to install (e.g. `arm64,riscv64,arm` ; default `all`) |
|
||||
|
||||
### outputs
|
||||
|
||||
@ -51,18 +52,7 @@ Following outputs are available
|
||||
|---------------|---------|---------------------------------------|
|
||||
| `platforms` | String | Available platforms (comma separated) |
|
||||
|
||||
## Keep up-to-date with GitHub Dependabot
|
||||
## Contributing
|
||||
|
||||
Since [Dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot)
|
||||
has [native GitHub Actions support](https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#package-ecosystem),
|
||||
to enable it on your GitHub repo all you need to do is add the `.github/dependabot.yml` file:
|
||||
|
||||
```yaml
|
||||
version: 2
|
||||
updates:
|
||||
# Maintain dependencies for GitHub Actions
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
```
|
||||
Want to contribute? Awesome! You can find information about contributing to
|
||||
this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
|
||||
|
2
dist/index.js
generated
vendored
2
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
13
dist/licenses.txt
generated
vendored
13
dist/licenses.txt
generated
vendored
@ -73,3 +73,16 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
uuid
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
@ -26,7 +26,7 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.6.0",
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
13
src/context.ts
Normal file
13
src/context.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
export interface Inputs {
|
||||
image: string;
|
||||
platforms: string;
|
||||
}
|
||||
|
||||
export function getInputs(): Inputs {
|
||||
return {
|
||||
image: core.getInput('image') || 'tonistiigi/binfmt:latest',
|
||||
platforms: core.getInput('platforms') || 'all'
|
||||
};
|
||||
}
|
34
src/exec.ts
34
src/exec.ts
@ -1,34 +0,0 @@
|
||||
import * as actionsExec from '@actions/exec';
|
||||
import {ExecOptions} from '@actions/exec';
|
||||
|
||||
export interface ExecResult {
|
||||
success: boolean;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
}
|
||||
|
||||
export const exec = async (command: string, args: string[] = [], silent: boolean): Promise<ExecResult> => {
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
|
||||
const options: ExecOptions = {
|
||||
silent: silent,
|
||||
ignoreReturnCode: true
|
||||
};
|
||||
options.listeners = {
|
||||
stdout: (data: Buffer) => {
|
||||
stdout += data.toString();
|
||||
},
|
||||
stderr: (data: Buffer) => {
|
||||
stderr += data.toString();
|
||||
}
|
||||
};
|
||||
|
||||
const returnCode: number = await actionsExec.exec(command, args, options);
|
||||
|
||||
return {
|
||||
success: returnCode === 0,
|
||||
stdout: stdout.trim(),
|
||||
stderr: stderr.trim()
|
||||
};
|
||||
};
|
72
src/main.ts
72
src/main.ts
@ -1,7 +1,6 @@
|
||||
import * as mexec from './exec';
|
||||
import * as context from './context';
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import {issueCommand} from '@actions/core/lib/command';
|
||||
|
||||
interface Platforms {
|
||||
supported: string[];
|
||||
@ -10,44 +9,47 @@ interface Platforms {
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
core.startGroup(`Docker info`);
|
||||
await exec.exec('docker', ['version']);
|
||||
await exec.exec('docker', ['info']);
|
||||
core.endGroup();
|
||||
const input: context.Inputs = context.getInputs();
|
||||
|
||||
const image: string = core.getInput('image') || 'tonistiigi/binfmt:latest';
|
||||
const platforms: string = core.getInput('platforms') || 'all';
|
||||
|
||||
core.startGroup(`Pulling binfmt Docker image`);
|
||||
await exec.exec('docker', ['pull', image]);
|
||||
core.endGroup();
|
||||
|
||||
core.startGroup(`Image info`);
|
||||
await exec.exec('docker', ['image', 'inspect', image]);
|
||||
core.endGroup();
|
||||
|
||||
core.startGroup(`Installing QEMU static binaries`);
|
||||
await exec.exec('docker', ['run', '--rm', '--privileged', image, '--install', platforms]);
|
||||
core.endGroup();
|
||||
|
||||
core.startGroup(`Extracting available platforms`);
|
||||
await mexec.exec(`docker`, ['run', '--rm', '--privileged', image], true).then(res => {
|
||||
if (res.stderr != '' && !res.success) {
|
||||
throw new Error(res.stderr);
|
||||
}
|
||||
const platforms: Platforms = JSON.parse(res.stdout.trim());
|
||||
core.info(`${platforms.supported.join(',')}`);
|
||||
setOutput('platforms', platforms.supported.join(','));
|
||||
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(',')}`);
|
||||
core.setOutput('platforms', platforms.supported.join(','));
|
||||
});
|
||||
});
|
||||
core.endGroup();
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
||||
function setOutput(name: string, value: unknown): void {
|
||||
issueCommand('set-output', {name}, value);
|
||||
}
|
||||
|
||||
run();
|
||||
|
28
yarn.lock
28
yarn.lock
@ -2,12 +2,13 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@actions/core@^1.6.0":
|
||||
version "1.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.6.0.tgz#0568e47039bfb6a9170393a73f3b7eb3b22462cb"
|
||||
integrity sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==
|
||||
"@actions/core@^1.10.0":
|
||||
version "1.10.0"
|
||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.0.tgz#44551c3c71163949a2f06e94d9ca2157a0cfac4f"
|
||||
integrity sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==
|
||||
dependencies:
|
||||
"@actions/http-client" "^1.0.11"
|
||||
"@actions/http-client" "^2.0.1"
|
||||
uuid "^8.3.2"
|
||||
|
||||
"@actions/exec@^1.1.1":
|
||||
version "1.1.1"
|
||||
@ -16,12 +17,12 @@
|
||||
dependencies:
|
||||
"@actions/io" "^1.0.1"
|
||||
|
||||
"@actions/http-client@^1.0.11":
|
||||
version "1.0.11"
|
||||
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.11.tgz#c58b12e9aa8b159ee39e7dd6cbd0e91d905633c0"
|
||||
integrity sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==
|
||||
"@actions/http-client@^2.0.1":
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.0.1.tgz#873f4ca98fe32f6839462a6f046332677322f99c"
|
||||
integrity sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==
|
||||
dependencies:
|
||||
tunnel "0.0.6"
|
||||
tunnel "^0.0.6"
|
||||
|
||||
"@actions/io@^1.0.1":
|
||||
version "1.0.2"
|
||||
@ -919,7 +920,7 @@ tsutils@^3.21.0:
|
||||
dependencies:
|
||||
tslib "^1.8.1"
|
||||
|
||||
tunnel@0.0.6:
|
||||
tunnel@^0.0.6:
|
||||
version "0.0.6"
|
||||
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
|
||||
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==
|
||||
@ -948,6 +949,11 @@ uri-js@^4.2.2:
|
||||
dependencies:
|
||||
punycode "^2.1.0"
|
||||
|
||||
uuid@^8.3.2:
|
||||
version "8.3.2"
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
||||
|
||||
v8-compile-cache-lib@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz#0582bcb1c74f3a2ee46487ceecf372e46bce53e8"
|
||||
|
Reference in New Issue
Block a user