From 5290010a6f3e3d120ee6b0ff916b57c1c4e86ee3 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 7 Aug 2020 19:14:30 +0200 Subject: [PATCH] Add install input to set buildx as default builder (#71) Signed-off-by: CrazyMax --- .github/workflows/setup-buildx-ci.yml | 22 ++++++++++++++++------ setup-buildx/README.md | 1 + setup-buildx/action.yml | 4 ++++ setup-buildx/dist/index.js | 5 +++++ setup-buildx/src/main.ts | 6 ++++++ 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/setup-buildx-ci.yml b/.github/workflows/setup-buildx-ci.yml index 1026245..fffc133 100644 --- a/.github/workflows/setup-buildx-ci.yml +++ b/.github/workflows/setup-buildx-ci.yml @@ -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: @@ -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 diff --git a/setup-buildx/README.md b/setup-buildx/README.md index ac21d58..071f635 100644 --- a/setup-buildx/README.md +++ b/setup-buildx/README.md @@ -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 diff --git a/setup-buildx/action.yml b/setup-buildx/action.yml index d970cfd..b1871bb 100644 --- a/setup-buildx/action.yml +++ b/setup-buildx/action.yml @@ -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: diff --git a/setup-buildx/dist/index.js b/setup-buildx/dist/index.js index 3fea34d..7477162 100644 --- a/setup-buildx/dist/index.js +++ b/setup-buildx/dist/index.js @@ -2492,6 +2492,7 @@ function run() { return; } const buildxVer = core.getInput('buildx-version') || 'latest'; + const install = /true/i.test(core.getInput('install')); const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker'); yield installer.buildx(buildxVer, dockerConfigHome); core.info('📣 Buildx info'); @@ -2508,6 +2509,10 @@ function run() { ]); core.info('🏃 Booting builder...'); yield exec.exec('docker', ['buildx', 'inspect', '--bootstrap']); + if (install) { + core.info('🤝 Setting buildx as default builder...'); + yield exec.exec('docker', ['buildx', 'install']); + } core.info('🐳 Docker info'); yield exec.exec('docker', ['info']); core.info('🛒 Extracting available platforms...'); diff --git a/setup-buildx/src/main.ts b/setup-buildx/src/main.ts index 30bc977..b50d165 100644 --- a/setup-buildx/src/main.ts +++ b/setup-buildx/src/main.ts @@ -14,6 +14,7 @@ async function run(): Promise { } 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); @@ -34,6 +35,11 @@ async function run(): Promise { 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']);