mirror of
https://github.com/docker/build-push-action
synced 2024-11-10 05:21:40 +00:00
Add 'use' input
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
d0f7649930
commit
15c6a86f2d
5 changed files with 36 additions and 3 deletions
22
.github/workflows/setup-buildx-ci.yml
vendored
22
.github/workflows/setup-buildx-ci.yml
vendored
|
@ -62,6 +62,28 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
docker build --help
|
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:
|
driver:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
|
|
|
@ -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` | 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` |
|
| `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` |
|
| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` |
|
||||||
|
| `use` | Bool | `true` | Switch to this builder instance |
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,10 @@ inputs:
|
||||||
description: 'Sets up docker build command as an alias to docker buildx'
|
description: 'Sets up docker build command as an alias to docker buildx'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
|
use:
|
||||||
|
description: 'Switch to this builder instance'
|
||||||
|
default: 'true'
|
||||||
|
required: false
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
platforms:
|
platforms:
|
||||||
|
|
5
setup-buildx/dist/index.js
generated
vendored
5
setup-buildx/dist/index.js
generated
vendored
|
@ -2495,6 +2495,7 @@ function run() {
|
||||||
const driver = core.getInput('driver') || 'docker-container';
|
const driver = core.getInput('driver') || 'docker-container';
|
||||||
const driverOpt = core.getInput('driver-opt');
|
const driverOpt = core.getInput('driver-opt');
|
||||||
const install = /true/i.test(core.getInput('install'));
|
const install = /true/i.test(core.getInput('install'));
|
||||||
|
const use = /true/i.test(core.getInput('use'));
|
||||||
const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
|
const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
|
||||||
yield installer.buildx(buildxVer, dockerConfigHome);
|
yield installer.buildx(buildxVer, dockerConfigHome);
|
||||||
core.info('📣 Buildx info');
|
core.info('📣 Buildx info');
|
||||||
|
@ -2503,7 +2504,6 @@ function run() {
|
||||||
let createArgs = [
|
let createArgs = [
|
||||||
'buildx',
|
'buildx',
|
||||||
'create',
|
'create',
|
||||||
'--use',
|
|
||||||
'--name',
|
'--name',
|
||||||
`builder-${process.env.GITHUB_SHA}`,
|
`builder-${process.env.GITHUB_SHA}`,
|
||||||
'--driver',
|
'--driver',
|
||||||
|
@ -2512,6 +2512,9 @@ function run() {
|
||||||
if (driverOpt) {
|
if (driverOpt) {
|
||||||
createArgs.push('--driver-opt', driverOpt);
|
createArgs.push('--driver-opt', driverOpt);
|
||||||
}
|
}
|
||||||
|
if (use) {
|
||||||
|
createArgs.push('--use');
|
||||||
|
}
|
||||||
yield exec.exec('docker', createArgs);
|
yield exec.exec('docker', createArgs);
|
||||||
core.info('🏃 Booting builder...');
|
core.info('🏃 Booting builder...');
|
||||||
yield exec.exec('docker', ['buildx', 'inspect', '--bootstrap']);
|
yield exec.exec('docker', ['buildx', 'inspect', '--bootstrap']);
|
||||||
|
|
|
@ -17,6 +17,8 @@ async function run(): Promise<void> {
|
||||||
const driver: string = core.getInput('driver') || 'docker-container';
|
const driver: string = core.getInput('driver') || 'docker-container';
|
||||||
const driverOpt: string = core.getInput('driver-opt');
|
const driverOpt: string = core.getInput('driver-opt');
|
||||||
const install: boolean = /true/i.test(core.getInput('install'));
|
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');
|
const dockerConfigHome: string = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
|
||||||
await installer.buildx(buildxVer, dockerConfigHome);
|
await installer.buildx(buildxVer, dockerConfigHome);
|
||||||
|
|
||||||
|
@ -27,16 +29,17 @@ async function run(): Promise<void> {
|
||||||
let createArgs: Array<string> = [
|
let createArgs: Array<string> = [
|
||||||
'buildx',
|
'buildx',
|
||||||
'create',
|
'create',
|
||||||
'--use',
|
|
||||||
'--name',
|
'--name',
|
||||||
`builder-${process.env.GITHUB_SHA}`,
|
`builder-${process.env.GITHUB_SHA}`,
|
||||||
'--driver',
|
'--driver',
|
||||||
driver
|
driver
|
||||||
];
|
];
|
||||||
|
|
||||||
if (driverOpt) {
|
if (driverOpt) {
|
||||||
createArgs.push('--driver-opt', driverOpt);
|
createArgs.push('--driver-opt', driverOpt);
|
||||||
}
|
}
|
||||||
|
if (use) {
|
||||||
|
createArgs.push('--use');
|
||||||
|
}
|
||||||
|
|
||||||
await exec.exec('docker', createArgs);
|
await exec.exec('docker', createArgs);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue