We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 8b562ef + c3bed4e commit fdbeaacCopy full SHA for fdbeaac
8 files changed
.github/workflows/ci.yml
@@ -79,3 +79,26 @@ jobs:
79
echo "::error::Should have failed"
80
exit 1
81
fi
82
+
83
+ cache-image:
84
+ runs-on: ubuntu-latest
85
+ strategy:
86
+ fail-fast: false
87
+ matrix:
88
+ cache:
89
+ - true
90
+ - false
91
+ steps:
92
+ -
93
+ name: Checkout
94
+ uses: actions/checkout@v4
95
96
+ name: Set up QEMU
97
+ id: qemu
98
+ uses: ./
99
+ with:
100
+ image: tonistiigi/binfmt:master
101
+ cache-image: ${{ matrix.cache }}
102
103
+ name: Available platforms
104
+ run: echo ${{ steps.qemu.outputs.platforms }}
README.md
@@ -41,10 +41,11 @@ jobs:
41
42
The following inputs can be used as `step.with` keys:
43
44
-| Name | Type | Default | Description |
45
-|-------------|--------|-------------------------------------------------------------------------------|--------------------------------------------------|
46
-| `image` | String | [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) | QEMU static binaries Docker image |
47
-| `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`) |
48
+| `cache-image` | Bool | `true` | Cache binfmt image to GitHub Actions cache backend |
49
50
### outputs
51
__tests__/context.test.ts
@@ -16,31 +16,38 @@ describe('getInputs', () => {
16
test.each([
17
[
18
0,
19
- new Map<string, string>([]),
+ new Map<string, string>([
20
+ ['cache-image', 'true'],
21
+ ]),
22
{
23
image: 'docker.io/tonistiigi/binfmt:latest',
24
platforms: 'all',
25
+ cacheImage: true,
26
} as context.Inputs
27
],
28
29
1,
30
new Map<string, string>([
31
['image', 'docker/binfmt:latest'],
32
['platforms', 'arm64,riscv64,arm'],
33
+ ['cache-image', 'false'],
34
]),
35
36
image: 'docker/binfmt:latest',
37
platforms: 'arm64,riscv64,arm',
38
+ cacheImage: false,
39
40
2,
['platforms', 'arm64, riscv64, arm '],
52
]
53
])(
action.yml
@@ -15,6 +15,10 @@ inputs:
15
description: 'Platforms to install (e.g. arm64,riscv64,arm)'
default: 'all'
required: false
+ 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'
dist/index.js
dist/index.js.map
src/context.ts
@@ -4,11 +4,13 @@ import {Util} from '@docker/actions-toolkit/lib/util';
4
export interface Inputs {
5
image: string;
6
platforms: string;
7
+ cacheImage: boolean;
8
}
9
10
export function getInputs(): Inputs {
11
return {
12
image: core.getInput('image') || 'docker.io/tonistiigi/binfmt:latest',
- platforms: Util.getInputList('platforms').join(',') || 'all'
13
+ platforms: Util.getInputList('platforms').join(',') || 'all',
14
+ cacheImage: core.getBooleanInput('cache-image')
};
src/main.ts
@@ -20,13 +20,7 @@ actionsToolkit.run(
});
await core.group(`Pulling binfmt Docker image`, async () => {
- 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 Docker.pull(input.image, input.cacheImage);
await core.group(`Image info`, async () => {
0 commit comments