Uninstall current emulators

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2022-10-08 19:08:44 +02:00
parent e81a89b173
commit 3496826faa
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
7 changed files with 43 additions and 17 deletions

View File

@ -2,7 +2,7 @@ name: ci
on: on:
schedule: schedule:
- cron: '0 10 * * *' # everyday at 10am - cron: '0 10 * * *'
push: push:
branches: branches:
- 'master' - 'master'
@ -40,9 +40,6 @@ jobs:
- -
name: Available platforms name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }} run: echo ${{ steps.qemu.outputs.platforms }}
-
name: Dump context
uses: crazy-max/ghaction-dump-context@v1
error: error:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -67,7 +64,23 @@ jobs:
echo "::error::Should have failed" echo "::error::Should have failed"
exit 1 exit 1
fi fi
reset:
runs-on: ubuntu-latest
steps:
- -
name: Dump context name: Checkout
if: always() uses: actions/checkout@v3
uses: crazy-max/ghaction-dump-context@v1 -
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: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}

View File

@ -39,18 +39,19 @@ jobs:
Following inputs can be used as `step.with` keys Following inputs can be used as `step.with` keys
| Name | Type | Description | | Name | Type | Default | Description |
|-------------|--------|---------------------------------------------------------------------------------------------------------------------------| |-------------|--------|-------------------------------------------------------------------------------|-------------------------------------------------|
| `image` | String | QEMU static binaries Docker image (default [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags)) | | `image` | String | [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) | QEMU static binaries Docker image |
| `platforms` | String | Platforms to install (e.g. `arm64,riscv64,arm` ; default `all`) | | `platforms` | String | `all` | Platforms to install |
| `reset` | Bool | `false` | Uninstall current emulators before installation |
### outputs ### outputs
Following outputs are available Following outputs are available
| Name | Type | Description | | Name | Type | Description |
|---------------|---------|---------------------------------------| |-------------|---------|---------------------------------------|
| `platforms` | String | Available platforms (comma separated) | | `platforms` | String | Available platforms (comma separated) |
## Contributing ## Contributing

View File

@ -15,6 +15,10 @@ inputs:
description: 'Platforms to install (e.g. arm64,riscv64,arm)' description: 'Platforms to install (e.g. arm64,riscv64,arm)'
default: 'all' default: 'all'
required: false required: false
reset:
description: 'Uninstall current emulators before installation'
default: 'false'
required: false
outputs: outputs:
platforms: platforms:

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -3,11 +3,13 @@ import * as core from '@actions/core';
export interface Inputs { export interface Inputs {
image: string; image: string;
platforms: string; platforms: string;
reset: boolean;
} }
export function getInputs(): Inputs { export function getInputs(): Inputs {
return { return {
image: core.getInput('image') || 'tonistiigi/binfmt:latest', image: core.getInput('image') || 'tonistiigi/binfmt:latest',
platforms: core.getInput('platforms') || 'all' platforms: core.getInput('platforms') || 'all',
reset: core.getBooleanInput('reset')
}; };
} }

View File

@ -24,6 +24,12 @@ async function run(): Promise<void> {
await exec.exec('docker', ['pull', input.image]); 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 core.group(`Image info`, async () => {
await exec.exec('docker', ['image', 'inspect', input.image]); await exec.exec('docker', ['image', 'inspect', input.image]);
}); });