Skip to content

Commit

Permalink
Uninstall current emulators
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Oct 8, 2022
1 parent e81a89b commit 3496826
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 17 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/ci.yml
Expand Up @@ -2,7 +2,7 @@ name: ci

on:
schedule:
- cron: '0 10 * * *' # everyday at 10am
- cron: '0 10 * * *'
push:
branches:
- 'master'
Expand Down Expand Up @@ -40,9 +40,6 @@ jobs:
-
name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
-
name: Dump context
uses: crazy-max/ghaction-dump-context@v1

error:
runs-on: ubuntu-latest
Expand All @@ -67,7 +64,23 @@ jobs:
echo "::error::Should have failed"
exit 1
fi
reset:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
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: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1
name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
15 changes: 8 additions & 7 deletions README.md
Expand Up @@ -39,18 +39,19 @@ jobs:

Following inputs can be used as `step.with` keys

| Name | Type | Description |
|-------------|--------|---------------------------------------------------------------------------------------------------------------------------|
| `image` | String | QEMU static binaries Docker image (default [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags)) |
| `platforms` | String | Platforms to install (e.g. `arm64,riscv64,arm` ; default `all`) |
| 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 |
| `reset` | Bool | `false` | Uninstall current emulators before installation |

### outputs

Following outputs are available

| Name | Type | Description |
|---------------|---------|---------------------------------------|
| `platforms` | String | Available platforms (comma separated) |
| Name | Type | Description |
|-------------|---------|---------------------------------------|
| `platforms` | String | Available platforms (comma separated) |

## Contributing

Expand Down
4 changes: 4 additions & 0 deletions action.yml
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

outputs:
platforms:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/context.ts
Expand Up @@ -3,11 +3,13 @@ import * as core from '@actions/core';
export interface Inputs {
image: string;
platforms: string;
reset: boolean;
}

export function getInputs(): Inputs {
return {
image: core.getInput('image') || 'tonistiigi/binfmt:latest',
platforms: core.getInput('platforms') || 'all'
platforms: core.getInput('platforms') || 'all',
reset: core.getBooleanInput('reset')
};
}
6 changes: 6 additions & 0 deletions src/main.ts
Expand Up @@ -24,6 +24,12 @@ async function run(): Promise<void> {
await exec.exec('docker', ['pull', input.image]);
});

if (input.reset) {
await core.group(`Uninstalling current emulators`, async () => {
await exec.exec('docker', ['run', '--rm', '--privileged', input.image, '--uninstall', 'qemu-*']);
});
}

await core.group(`Image info`, async () => {
await exec.exec('docker', ['image', 'inspect', input.image]);
});
Expand Down

0 comments on commit 3496826

Please sign in to comment.