Skip to content

Commit

Permalink
Add 'use' input
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 d0f7649 commit 15c6a86
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/setup-buildx-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ jobs:
run: |
docker build --help
use:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
use:
- true
- false
steps:
-
name: Checkout
uses: actions/checkout@v2.3.1
-
name: Set up Docker Buildx
id: buildx
uses: ./setup-buildx/
with:
use: ${{ matrix.use }}
-
name: List builder instances
run: docker buildx ls

driver:
runs-on: ubuntu-latest
strategy:
Expand Down
1 change: 1 addition & 0 deletions setup-buildx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Following inputs can be used as `step.with` keys
| `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` |
| `use` | Bool | `true` | Switch to this builder instance |

### 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 @@ -22,6 +22,10 @@ inputs:
description: 'Sets up docker build command as an alias to docker buildx'
default: 'false'
required: false
use:
description: 'Switch to this builder instance'
default: 'true'
required: false

outputs:
platforms:
Expand Down
5 changes: 4 additions & 1 deletion setup-buildx/dist/index.js

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

7 changes: 5 additions & 2 deletions setup-buildx/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ async function run(): Promise<void> {
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 use: boolean = /true/i.test(core.getInput('use'));

const dockerConfigHome: string = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
await installer.buildx(buildxVer, dockerConfigHome);

Expand All @@ -27,16 +29,17 @@ async function run(): Promise<void> {
let createArgs: Array<string> = [
'buildx',
'create',
'--use',
'--name',
`builder-${process.env.GITHUB_SHA}`,
'--driver',
driver
];

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

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

Expand Down

0 comments on commit 15c6a86

Please sign in to comment.