3
0
Fork 0
mirror of https://gitea.com/docker/build-push-action.git synced 2024-11-25 19:09:40 +01:00

Add install input to set buildx as default builder (#71)

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2020-08-07 19:14:30 +02:00
parent 925fee3dc9
commit 5290010a6f
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
5 changed files with 32 additions and 6 deletions

View file

@ -39,6 +39,22 @@ jobs:
name: Available platforms name: Available platforms
run: echo ${{ steps.buildx.outputs.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: with-qemu:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
@ -51,12 +67,6 @@ jobs:
- latest - latest
- 4.2.0-7 - 4.2.0-7
steps: steps:
-
name: Runner info
run: |
sudo apt-get install -y hwinfo
sudo hwinfo --short
sudo mount
- -
name: Checkout name: Checkout
uses: actions/checkout@v2.3.1 uses: actions/checkout@v2.3.1

View file

@ -91,6 +91,7 @@ Following inputs can be used as `step.with` keys
| Name | Type | Default | Description | | Name | Type | Default | Description |
|------------------|---------|-----------|------------------------------------| |------------------|---------|-----------|------------------------------------|
| `buildx-version` | String | `latest` | [Buildx](https://github.com/docker/buildx) version. Example: `v0.3.0` | | `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 ### outputs

View file

@ -11,6 +11,10 @@ inputs:
description: 'Buildx version. Example: v0.3.0' description: 'Buildx version. Example: v0.3.0'
default: 'latest' default: 'latest'
required: false required: false
install:
description: 'Sets up docker build command as an alias to docker buildx'
default: 'false'
required: false
outputs: outputs:
platforms: platforms:

5
setup-buildx/dist/index.js generated vendored
View file

@ -2492,6 +2492,7 @@ function run() {
return; return;
} }
const buildxVer = core.getInput('buildx-version') || 'latest'; 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'); 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');
@ -2508,6 +2509,10 @@ function run() {
]); ]);
core.info('🏃 Booting builder...'); core.info('🏃 Booting builder...');
yield exec.exec('docker', ['buildx', 'inspect', '--bootstrap']); 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'); core.info('🐳 Docker info');
yield exec.exec('docker', ['info']); yield exec.exec('docker', ['info']);
core.info('🛒 Extracting available platforms...'); core.info('🛒 Extracting available platforms...');

View file

@ -14,6 +14,7 @@ async function run(): Promise<void> {
} }
const buildxVer: string = core.getInput('buildx-version') || 'latest'; 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'); const dockerConfigHome: string = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
await installer.buildx(buildxVer, dockerConfigHome); await installer.buildx(buildxVer, dockerConfigHome);
@ -34,6 +35,11 @@ async function run(): Promise<void> {
core.info('🏃 Booting builder...'); core.info('🏃 Booting builder...');
await exec.exec('docker', ['buildx', 'inspect', '--bootstrap']); 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'); core.info('🐳 Docker info');
await exec.exec('docker', ['info']); await exec.exec('docker', ['info']);