Skip to content

Commit 3496826

Browse files
committed
Uninstall current emulators
Signed-off-by: CrazyMax <[email protected]>
1 parent e81a89b commit 3496826

File tree

7 files changed

+43
-17
lines changed

7 files changed

+43
-17
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: ci
22

33
on:
44
schedule:
5-
- cron: '0 10 * * *' # everyday at 10am
5+
- cron: '0 10 * * *'
66
push:
77
branches:
88
- 'master'
@@ -40,9 +40,6 @@ jobs:
4040
-
4141
name: Available platforms
4242
run: echo ${{ steps.qemu.outputs.platforms }}
43-
-
44-
name: Dump context
45-
uses: crazy-max/ghaction-dump-context@v1
4643

4744
error:
4845
runs-on: ubuntu-latest
@@ -67,7 +64,23 @@ jobs:
6764
echo "::error::Should have failed"
6865
exit 1
6966
fi
67+
68+
reset:
69+
runs-on: ubuntu-latest
70+
steps:
71+
-
72+
name: Checkout
73+
uses: actions/checkout@v3
74+
-
75+
name: Install multiarch/qemu-user-static
76+
run: |
77+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes -c yes
78+
-
79+
name: Set up QEMU
80+
id: qemu
81+
uses: ./
82+
with:
83+
reset: true
7084
-
71-
name: Dump context
72-
if: always()
73-
uses: crazy-max/ghaction-dump-context@v1
85+
name: Available platforms
86+
run: echo ${{ steps.qemu.outputs.platforms }}

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,19 @@ jobs:
3939
4040
Following inputs can be used as `step.with` keys
4141

42-
| Name | Type | Description |
43-
|-------------|--------|---------------------------------------------------------------------------------------------------------------------------|
44-
| `image` | String | QEMU static binaries Docker image (default [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags)) |
45-
| `platforms` | String | Platforms to install (e.g. `arm64,riscv64,arm` ; default `all`) |
42+
| Name | Type | Default | Description |
43+
|-------------|--------|-------------------------------------------------------------------------------|-------------------------------------------------|
44+
| `image` | String | [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) | QEMU static binaries Docker image |
45+
| `platforms` | String | `all` | Platforms to install |
46+
| `reset` | Bool | `false` | Uninstall current emulators before installation |
4647

4748
### outputs
4849

4950
Following outputs are available
5051

51-
| Name | Type | Description |
52-
|---------------|---------|---------------------------------------|
53-
| `platforms` | String | Available platforms (comma separated) |
52+
| Name | Type | Description |
53+
|-------------|---------|---------------------------------------|
54+
| `platforms` | String | Available platforms (comma separated) |
5455

5556
## Contributing
5657

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ inputs:
1515
description: 'Platforms to install (e.g. arm64,riscv64,arm)'
1616
default: 'all'
1717
required: false
18+
reset:
19+
description: 'Uninstall current emulators before installation'
20+
default: 'false'
21+
required: false
1822

1923
outputs:
2024
platforms:

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import * as core from '@actions/core';
33
export interface Inputs {
44
image: string;
55
platforms: string;
6+
reset: boolean;
67
}
78

89
export function getInputs(): Inputs {
910
return {
1011
image: core.getInput('image') || 'tonistiigi/binfmt:latest',
11-
platforms: core.getInput('platforms') || 'all'
12+
platforms: core.getInput('platforms') || 'all',
13+
reset: core.getBooleanInput('reset')
1214
};
1315
}

src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ async function run(): Promise<void> {
2424
await exec.exec('docker', ['pull', input.image]);
2525
});
2626

27+
if (input.reset) {
28+
await core.group(`Uninstalling current emulators`, async () => {
29+
await exec.exec('docker', ['run', '--rm', '--privileged', input.image, '--uninstall', 'qemu-*']);
30+
});
31+
}
32+
2733
await core.group(`Image info`, async () => {
2834
await exec.exec('docker', ['image', 'inspect', input.image]);
2935
});

0 commit comments

Comments
 (0)