Skip to content

Commit

Permalink
Add driver and driver-opt inputs for setup-buildx
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
CrazyMax committed Aug 12, 2020
1 parent 4bde7b1 commit 5cec6ce
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 19 deletions.
40 changes: 39 additions & 1 deletion .github/workflows/setup-buildx-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
- setup-buildx/**

jobs:
build:
main:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -62,6 +62,44 @@ jobs:
run: |
docker build --help
driver:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
driver:
- docker-container
- docker
steps:
-
name: Checkout
uses: actions/checkout@v2.3.1
-
name: Set up Docker Buildx
id: buildx
uses: ./setup-buildx/
with:
driver: ${{ matrix.driver }}

driver-opt:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
driver-opt:
- image=moby/buildkit:latest
- image=moby/buildkit:master
steps:
-
name: Checkout
uses: actions/checkout@v2.3.1
-
name: Set up Docker Buildx
id: buildx
uses: ./setup-buildx/
with:
driver-opt: ${{ matrix.driver-opt }}

with-qemu:
runs-on: ubuntu-latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/setup-qemu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
- setup-qemu/**

jobs:
build:
main:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
10 changes: 6 additions & 4 deletions setup-buildx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ jobs:
Following inputs can be used as `step.with` keys

| Name | Type | Default | Description |
|------------------|---------|-----------|------------------------------------|
| `buildx-version` | String | `latest` | [Buildx](https://github.com/docker/buildx) version. Example: `v0.3.0` |
| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` |
| Name | Type | Default | Description |
|------------------|---------|---------------------|------------------------------------|
| `buildx-version` | String | `latest` | [Buildx](https://github.com/docker/buildx) version. e.g. `v0.3.0` |
| `driver` | String | `docker-container` | Sets the [builder driver](https://github.com/docker/buildx#--driver-driver) to be used. |
| `driver-opt` | String | | Passes additional [driver-specific options](https://github.com/docker/buildx#--driver-opt-options). e.g. `image=moby/buildkit:master` |
| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` |

### outputs

Expand Down
9 changes: 8 additions & 1 deletion setup-buildx/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ branding:

inputs:
buildx-version:
description: 'Buildx version. Example: v0.3.0'
description: 'Buildx version. e.g. v0.3.0'
default: 'latest'
required: false
driver:
description: 'Sets the builder driver to be used'
default: 'docker-container'
required: false
driver-opt:
description: 'Passes additional driver-specific options. Eg. image=moby/buildkit:master'
required: false
install:
description: 'Sets up docker build command as an alias to docker buildx'
default: 'false'
Expand Down
14 changes: 10 additions & 4 deletions setup-buildx/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions setup-buildx/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ async function run(): Promise<void> {
}

const buildxVer: string = core.getInput('buildx-version') || 'latest';
const driver: string = core.getInput('driver') || 'docker-container';
const driverOpt: string = core.getInput('driver-opt');
const install: boolean = /true/i.test(core.getInput('install'));
const dockerConfigHome: string = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
await installer.buildx(buildxVer, dockerConfigHome);
Expand All @@ -22,15 +24,21 @@ async function run(): Promise<void> {
await exec.exec('docker', ['buildx', 'version']);

core.info('🔨 Creating a new builder instance...');
await exec.exec('docker', [
let createArgs: Array<string> = [
'buildx',
'create',
'--use',
'--name',
`builder-${process.env.GITHUB_SHA}`,
'--driver',
'docker-container',
'--use'
]);
driver
];

if (driverOpt) {
createArgs.push('--driver-opt', driverOpt);
}

await exec.exec('docker', createArgs);

core.info('🏃 Booting builder...');
await exec.exec('docker', ['buildx', 'inspect', '--bootstrap']);
Expand Down
4 changes: 2 additions & 2 deletions setup-qemu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Following inputs can be used as `step.with` keys

| Name | Type | Default | Description |
|------------------|---------|-----------------------------|------------------------------------|
| `image` | String | `tonistiigi/binfmt:latest` | QEMU static binaries Docker image. Example: [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) |
| `platforms` | String | `all` | Platforms to install. Example: `arm64,riscv64,arm` |
| `image` | String | `tonistiigi/binfmt:latest` | QEMU static binaries Docker image. e.g. [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) |
| `platforms` | String | `all` | Platforms to install. e.g. `arm64,riscv64,arm` |

### outputs

Expand Down
4 changes: 2 additions & 2 deletions setup-qemu/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ branding:

inputs:
image:
description: 'QEMU static binaries Docker image. Example: tonistiigi/binfmt:latest'
description: 'QEMU static binaries Docker image. e.g. tonistiigi/binfmt:latest'
default: 'tonistiigi/binfmt:latest'
required: false
platforms:
description: 'Platforms to install. Example: arm64,riscv64,arm'
description: 'Platforms to install. e.g. arm64,riscv64,arm'
default: 'all'
required: false

Expand Down

0 comments on commit 5cec6ce

Please sign in to comment.