mirror of
https://github.com/docker/setup-qemu-action.git
synced 2024-11-15 16:53:51 +08:00
cache-image input to enable/disable caching of binfmt image
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
e2a9378e4f
commit
4f3cb031e7
23
.github/workflows/ci.yml
vendored
23
.github/workflows/ci.yml
vendored
@ -65,3 +65,26 @@ jobs:
|
||||
echo "::error::Should have failed"
|
||||
exit 1
|
||||
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 }}
|
||||
|
@ -41,10 +41,11 @@ jobs:
|
||||
|
||||
The following inputs can be used as `step.with` keys:
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|-------------|--------|-------------------------------------------------------------------------------|--------------------------------------------------|
|
||||
| `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`) |
|
||||
| Name | Type | Default | Description |
|
||||
|---------------|--------|-------------------------------------------------------------------------------|----------------------------------------------------|
|
||||
| `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`) |
|
||||
| `cache-image` | Bool | `true` | Cache binfmt image to GitHub Actions cache backend |
|
||||
|
||||
### outputs
|
||||
|
||||
|
@ -16,10 +16,13 @@ describe('getInputs', () => {
|
||||
test.each([
|
||||
[
|
||||
0,
|
||||
new Map<string, string>([]),
|
||||
new Map<string, string>([
|
||||
['cache-image', 'true'],
|
||||
]),
|
||||
{
|
||||
image: 'tonistiigi/binfmt:latest',
|
||||
platforms: 'all',
|
||||
cacheImage: true,
|
||||
} as context.Inputs
|
||||
],
|
||||
[
|
||||
@ -27,20 +30,24 @@ describe('getInputs', () => {
|
||||
new Map<string, string>([
|
||||
['image', 'docker/binfmt:latest'],
|
||||
['platforms', 'arm64,riscv64,arm'],
|
||||
['cache-image', 'false'],
|
||||
]),
|
||||
{
|
||||
image: 'docker/binfmt:latest',
|
||||
platforms: 'arm64,riscv64,arm',
|
||||
cacheImage: false,
|
||||
} as context.Inputs
|
||||
],
|
||||
[
|
||||
2,
|
||||
new Map<string, string>([
|
||||
['platforms', 'arm64, riscv64, arm '],
|
||||
['cache-image', 'true'],
|
||||
]),
|
||||
{
|
||||
image: 'tonistiigi/binfmt:latest',
|
||||
platforms: 'arm64,riscv64,arm',
|
||||
cacheImage: true,
|
||||
} as context.Inputs
|
||||
]
|
||||
])(
|
||||
|
@ -15,6 +15,10 @@ inputs:
|
||||
description: 'Platforms to install (e.g. arm64,riscv64,arm)'
|
||||
default: 'all'
|
||||
required: false
|
||||
cache-image:
|
||||
description: 'Cache binfmt image to GitHub Actions cache backend'
|
||||
default: 'true'
|
||||
required: false
|
||||
|
||||
outputs:
|
||||
platforms:
|
||||
@ -23,3 +27,4 @@ outputs:
|
||||
runs:
|
||||
using: 'node20'
|
||||
main: 'dist/index.js'
|
||||
post: 'dist/index.js'
|
||||
|
@ -4,11 +4,13 @@ import {Util} from '@docker/actions-toolkit/lib/util';
|
||||
export interface Inputs {
|
||||
image: string;
|
||||
platforms: string;
|
||||
cacheImage: boolean;
|
||||
}
|
||||
|
||||
export function getInputs(): Inputs {
|
||||
return {
|
||||
image: core.getInput('image') || 'tonistiigi/binfmt:latest',
|
||||
platforms: Util.getInputList('platforms').join(',') || 'all'
|
||||
platforms: Util.getInputList('platforms').join(',') || 'all',
|
||||
cacheImage: core.getBooleanInput('cache-image')
|
||||
};
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ actionsToolkit.run(
|
||||
});
|
||||
|
||||
await core.group(`Pulling binfmt Docker image`, async () => {
|
||||
await Exec.exec('docker', ['pull', input.image]);
|
||||
await Docker.pull(input.image, input.cacheImage);
|
||||
});
|
||||
|
||||
await core.group(`Image info`, async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user