Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninstall current emulators #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Uninstall current emulators
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Oct 8, 2022
commit 3496826faad23184006fd4880bcacb7b5e440e45
27 changes: 20 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ name: ci

on:
schedule:
- cron: '0 10 * * *' # everyday at 10am
- cron: '0 10 * * *'
push:
branches:
- 'master'
@@ -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
@@ -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
Original file line number Diff line number Diff line change
@@ -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

4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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:
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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]);
});