Compare commits

..

No commits in common. "fdbeaac5ff9cf5a81bfc642fc03727ea5a9dacd7" and "8b562efa09ec1557a9e26f25a7c6292838acea94" have entirely different histories.

8 changed files with 15 additions and 47 deletions

View File

@ -79,26 +79,3 @@ jobs:
echo "::error::Should have failed" echo "::error::Should have failed"
exit 1 exit 1
fi fi
cache-image:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cache:
- true
- false
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
id: qemu
uses: ./
with:
image: tonistiigi/binfmt:master
cache-image: ${{ matrix.cache }}
-
name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}

View File

@ -41,11 +41,10 @@ jobs:
The following inputs can be used as `step.with` keys: The following inputs can be used as `step.with` keys:
| Name | Type | Default | Description | | Name | Type | Default | Description |
|---------------|--------|-------------------------------------------------------------------------------|----------------------------------------------------| |-------------|--------|-------------------------------------------------------------------------------|--------------------------------------------------|
| `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`) |
| `cache-image` | Bool | `true` | Cache binfmt image to GitHub Actions cache backend |
### outputs ### outputs

View File

@ -16,13 +16,10 @@ describe('getInputs', () => {
test.each([ test.each([
[ [
0, 0,
new Map<string, string>([ new Map<string, string>([]),
['cache-image', 'true'],
]),
{ {
image: 'docker.io/tonistiigi/binfmt:latest', image: 'docker.io/tonistiigi/binfmt:latest',
platforms: 'all', platforms: 'all',
cacheImage: true,
} as context.Inputs } as context.Inputs
], ],
[ [
@ -30,24 +27,20 @@ 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'],
['cache-image', 'false'],
]), ]),
{ {
image: 'docker/binfmt:latest', image: 'docker/binfmt:latest',
platforms: 'arm64,riscv64,arm', platforms: 'arm64,riscv64,arm',
cacheImage: false,
} as context.Inputs } as context.Inputs
], ],
[ [
2, 2,
new Map<string, string>([ new Map<string, string>([
['platforms', 'arm64, riscv64, arm '], ['platforms', 'arm64, riscv64, arm '],
['cache-image', 'true'],
]), ]),
{ {
image: 'docker.io/tonistiigi/binfmt:latest', image: 'docker.io/tonistiigi/binfmt:latest',
platforms: 'arm64,riscv64,arm', platforms: 'arm64,riscv64,arm',
cacheImage: true,
} as context.Inputs } as context.Inputs
] ]
])( ])(

View File

@ -15,10 +15,6 @@ 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
cache-image:
description: 'Cache binfmt image to GitHub Actions cache backend'
default: 'true'
required: false
outputs: outputs:
platforms: platforms:
@ -27,4 +23,3 @@ outputs:
runs: runs:
using: 'node20' using: 'node20'
main: 'dist/index.js' main: 'dist/index.js'
post: 'dist/index.js'

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -4,13 +4,11 @@ import {Util} from '@docker/actions-toolkit/lib/util';
export interface Inputs { export interface Inputs {
image: string; image: string;
platforms: string; platforms: string;
cacheImage: boolean;
} }
export function getInputs(): Inputs { 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'
cacheImage: core.getBooleanInput('cache-image')
}; };
} }

View File

@ -20,7 +20,13 @@ actionsToolkit.run(
}); });
await core.group(`Pulling binfmt Docker image`, async () => { await core.group(`Pulling binfmt Docker image`, async () => {
await Docker.pull(input.image, input.cacheImage); await Docker.getExecOutput(['pull', input.image], {
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(`Image info`, async () => { await core.group(`Image info`, async () => {