mirror of
https://github.com/docker/setup-qemu-action.git
synced 2026-05-28 00:58:18 +01:00
Merge pull request #21 from crazy-max/uninst
uninstall current emulators
This commit is contained in:
20
.github/workflows/ci.yml
vendored
20
.github/workflows/ci.yml
vendored
@@ -125,3 +125,23 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
image: ${{ matrix.image }}
|
image: ${{ matrix.image }}
|
||||||
|
|
||||||
|
reset:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
|
-
|
||||||
|
name: Install multiarch/qemu-user-static
|
||||||
|
run: |
|
||||||
|
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes -c yes
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
id: qemu
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
reset: true
|
||||||
|
-
|
||||||
|
name: Available platforms
|
||||||
|
run: echo ${{ steps.qemu.outputs.platforms }}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ The following inputs can be used as `step.with` keys:
|
|||||||
|---------------|--------|-------------------------------------------------------------------------------|----------------------------------------------------|
|
|---------------|--------|-------------------------------------------------------------------------------|----------------------------------------------------|
|
||||||
| `image` | String | [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) | QEMU static binaries Docker image |
|
| `image` | String | [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) | QEMU static binaries Docker image |
|
||||||
| `platforms` | String | `all` | Platforms to install (e.g., `arm64,riscv64,arm`) |
|
| `platforms` | String | `all` | Platforms to install (e.g., `arm64,riscv64,arm`) |
|
||||||
|
| `reset` | Bool | `false` | Uninstall current emulators before installation |
|
||||||
| `cache-image` | Bool | `true` | Cache binfmt image to GitHub Actions cache backend |
|
| `cache-image` | Bool | `true` | Cache binfmt image to GitHub Actions cache backend |
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|||||||
@@ -17,11 +17,13 @@ describe('getInputs', () => {
|
|||||||
[
|
[
|
||||||
0,
|
0,
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['reset', 'false'],
|
||||||
['cache-image', 'true'],
|
['cache-image', 'true'],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
image: 'docker.io/tonistiigi/binfmt:latest',
|
image: 'docker.io/tonistiigi/binfmt:latest',
|
||||||
platforms: 'all',
|
platforms: 'all',
|
||||||
|
reset: false,
|
||||||
cacheImage: true,
|
cacheImage: true,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -30,11 +32,13 @@ describe('getInputs', () => {
|
|||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['image', 'docker/binfmt:latest'],
|
['image', 'docker/binfmt:latest'],
|
||||||
['platforms', 'arm64,riscv64,arm'],
|
['platforms', 'arm64,riscv64,arm'],
|
||||||
|
['reset', 'false'],
|
||||||
['cache-image', 'false'],
|
['cache-image', 'false'],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
image: 'docker/binfmt:latest',
|
image: 'docker/binfmt:latest',
|
||||||
platforms: 'arm64,riscv64,arm',
|
platforms: 'arm64,riscv64,arm',
|
||||||
|
reset: false,
|
||||||
cacheImage: false,
|
cacheImage: false,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -42,11 +46,13 @@ describe('getInputs', () => {
|
|||||||
2,
|
2,
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['platforms', 'arm64, riscv64, arm '],
|
['platforms', 'arm64, riscv64, arm '],
|
||||||
|
['reset', 'false'],
|
||||||
['cache-image', 'true'],
|
['cache-image', 'true'],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
image: 'docker.io/tonistiigi/binfmt:latest',
|
image: 'docker.io/tonistiigi/binfmt:latest',
|
||||||
platforms: 'arm64,riscv64,arm',
|
platforms: 'arm64,riscv64,arm',
|
||||||
|
reset: false,
|
||||||
cacheImage: true,
|
cacheImage: true,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ inputs:
|
|||||||
description: 'Platforms to install (e.g. arm64,riscv64,arm)'
|
description: 'Platforms to install (e.g. arm64,riscv64,arm)'
|
||||||
default: 'all'
|
default: 'all'
|
||||||
required: false
|
required: false
|
||||||
|
reset:
|
||||||
|
description: 'Uninstall current emulators before installation'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
cache-image:
|
cache-image:
|
||||||
description: 'Cache binfmt image to GitHub Actions cache backend'
|
description: 'Cache binfmt image to GitHub Actions cache backend'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
|
|||||||
106
dist/index.cjs
generated
vendored
106
dist/index.cjs
generated
vendored
File diff suppressed because one or more lines are too long
4
dist/index.cjs.map
generated
vendored
4
dist/index.cjs.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -4,6 +4,7 @@ import {Util} from '@docker/actions-toolkit/lib/util.js';
|
|||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
image: string;
|
image: string;
|
||||||
platforms: string;
|
platforms: string;
|
||||||
|
reset: boolean;
|
||||||
cacheImage: boolean;
|
cacheImage: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,6 +12,7 @@ export function getInputs(): Inputs {
|
|||||||
return {
|
return {
|
||||||
image: core.getInput('image') || 'docker.io/tonistiigi/binfmt:latest',
|
image: core.getInput('image') || 'docker.io/tonistiigi/binfmt:latest',
|
||||||
platforms: Util.getInputList('platforms').join(',') || 'all',
|
platforms: Util.getInputList('platforms').join(',') || 'all',
|
||||||
|
reset: core.getBooleanInput('reset'),
|
||||||
cacheImage: core.getBooleanInput('cache-image')
|
cacheImage: core.getBooleanInput('cache-image')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/main.ts
12
src/main.ts
@@ -44,6 +44,18 @@ actionsToolkit.run(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (input.reset) {
|
||||||
|
await core.group(`Uninstalling current emulators`, async () => {
|
||||||
|
await Docker.getExecOutput(['run', '--rm', '--privileged', input.image, '--uninstall', 'qemu-*'], {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await core.group(`Installing QEMU static binaries`, async () => {
|
await core.group(`Installing QEMU static binaries`, async () => {
|
||||||
await Docker.getExecOutput(['run', '--rm', '--privileged', input.image, '--install', input.platforms], {
|
await Docker.getExecOutput(['run', '--rm', '--privileged', input.image, '--install', input.platforms], {
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
|
|||||||
Reference in New Issue
Block a user