Skip to content

Commit

Permalink
Add install input to set buildx as default builder (#71)
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 Aug 11, 2020
1 parent 925fee3 commit 5290010
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/setup-buildx-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ jobs:
name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

install:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2.3.1
-
name: Set up Docker Buildx
uses: ./setup-buildx/
with:
install: true
-
name: Check cmd
run: |
docker build --help
with-qemu:
runs-on: ubuntu-latest
strategy:
Expand All @@ -51,12 +67,6 @@ jobs:
- latest
- 4.2.0-7
steps:
-
name: Runner info
run: |
sudo apt-get install -y hwinfo
sudo hwinfo --short
sudo mount
-
name: Checkout
uses: actions/checkout@v2.3.1
Expand Down
1 change: 1 addition & 0 deletions setup-buildx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ 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` |

### outputs

Expand Down
4 changes: 4 additions & 0 deletions setup-buildx/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
description: 'Buildx version. Example: v0.3.0'
default: 'latest'
required: false
install:
description: 'Sets up docker build command as an alias to docker buildx'
default: 'false'
required: false

outputs:
platforms:
Expand Down
5 changes: 5 additions & 0 deletions setup-buildx/dist/index.js

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

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

const buildxVer: string = core.getInput('buildx-version') || 'latest';
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 @@ -34,6 +35,11 @@ async function run(): Promise<void> {
core.info('🏃 Booting builder...');
await exec.exec('docker', ['buildx', 'inspect', '--bootstrap']);

if (install) {
core.info('🤝 Setting buildx as default builder...');
await exec.exec('docker', ['buildx', 'install']);
}

core.info('🐳 Docker info');
await exec.exec('docker', ['info']);

Expand Down

0 comments on commit 5290010

Please sign in to comment.