Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,23 @@ jobs:
uses: ./
with:
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 }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| `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 |

### outputs
Expand Down
6 changes: 6 additions & 0 deletions __tests__/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ describe('getInputs', () => {
[
0,
new Map<string, string>([
['reset', 'false'],
['cache-image', 'true'],
]),
{
image: 'docker.io/tonistiigi/binfmt:latest',
platforms: 'all',
reset: false,
cacheImage: true,
}
],
Expand All @@ -30,23 +32,27 @@ describe('getInputs', () => {
new Map<string, string>([
['image', 'docker/binfmt:latest'],
['platforms', 'arm64,riscv64,arm'],
['reset', 'false'],
['cache-image', 'false'],
]),
{
image: 'docker/binfmt:latest',
platforms: 'arm64,riscv64,arm',
reset: false,
cacheImage: false,
}
],
[
2,
new Map<string, string>([
['platforms', 'arm64, riscv64, arm '],
['reset', 'false'],
['cache-image', 'true'],
]),
{
image: 'docker.io/tonistiigi/binfmt:latest',
platforms: 'arm64,riscv64,arm',
reset: false,
cacheImage: true,
}
]
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ inputs:
description: 'Platforms to install (e.g. arm64,riscv64,arm)'
default: 'all'
required: false
reset:
description: 'Uninstall current emulators before installation'
default: 'false'
required: false
cache-image:
description: 'Cache binfmt image to GitHub Actions cache backend'
default: 'true'
Expand Down
106 changes: 53 additions & 53 deletions dist/index.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/index.cjs.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import {Util} from '@docker/actions-toolkit/lib/util.js';
export interface Inputs {
image: string;
platforms: string;
reset: boolean;
cacheImage: boolean;
}

export function getInputs(): Inputs {
return {
image: core.getInput('image') || 'docker.io/tonistiigi/binfmt:latest',
platforms: Util.getInputList('platforms').join(',') || 'all',
reset: core.getBooleanInput('reset'),
cacheImage: core.getBooleanInput('cache-image')
};
}
12 changes: 12 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 Docker.getExecOutput(['run', '--rm', '--privileged', input.image, '--install', input.platforms], {
ignoreReturnCode: true
Expand Down
Loading