Compare commits

..

1 Commits

5 changed files with 58 additions and 46 deletions

View File

@ -392,12 +392,12 @@ jobs:
type=sha type=sha
- -
name: Build name: Build
uses: docker/bake-action@v6 uses: docker/bake-action@v5
with: with:
files: | files: |
./test/docker-bake.hcl ./test/docker-bake.hcl
cwd://${{ steps.docker_meta.outputs.bake-file-tags }} ${{ steps.docker_meta.outputs.bake-file-tags }}
cwd://${{ steps.docker_meta.outputs.bake-file-labels }} ${{ steps.docker_meta.outputs.bake-file-labels }}
targets: | targets: |
release release
@ -504,12 +504,12 @@ jobs:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
- -
name: Build name: Build
uses: docker/bake-action@v6 uses: docker/bake-action@v5
with: with:
files: | files: |
./test/docker-bake.hcl ./test/docker-bake.hcl
cwd://${{ steps.docker_meta.outputs.bake-file-tags }} ${{ steps.docker_meta.outputs.bake-file-tags }}
cwd://${{ steps.docker_meta.outputs.bake-file-annotations }} ${{ steps.docker_meta.outputs.bake-file-annotations }}
targets: | targets: |
release release
@ -539,7 +539,7 @@ jobs:
name: Print envs name: Print envs
run: env|sort run: env|sort
bake-path-context: bake-cwd:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- -
@ -556,13 +556,13 @@ jobs:
uses: ./ uses: ./
- -
name: Build name: Build
uses: docker/bake-action@v6 uses: docker/bake-action@v5
with: with:
source: . source: "{{defaultContext}}"
files: | files: |
./test/docker-bake.hcl ./test/docker-bake.hcl
${{ steps.docker_meta.outputs.bake-file-tags }} cwd://${{ steps.docker_meta.outputs.bake-file-tags }}
${{ steps.docker_meta.outputs.bake-file-labels }} cwd://${{ steps.docker_meta.outputs.bake-file-labels }}
targets: | targets: |
release release

View File

@ -15,9 +15,12 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Test name: Test
uses: docker/bake-action@v6 uses: docker/bake-action@v5
with: with:
targets: test targets: test
- -

View File

@ -15,17 +15,16 @@ jobs:
prepare: prepare:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
targets: ${{ steps.generate.outputs.targets }} targets: ${{ steps.targets.outputs.matrix }}
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- -
name: List targets name: Targets matrix
id: generate id: targets
uses: docker/bake-action/subaction/list-targets@v6 run: |
with: echo "matrix=$(docker buildx bake validate --print | jq -cr '.group.validate.targets')" >> $GITHUB_OUTPUT
target: validate
validate: validate:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -36,8 +35,11 @@ jobs:
matrix: matrix:
target: ${{ fromJson(needs.prepare.outputs.targets) }} target: ${{ fromJson(needs.prepare.outputs.targets) }}
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Validate name: Validate
uses: docker/bake-action@v6 uses: docker/bake-action@v5
with: with:
targets: ${{ matrix.target }} targets: ${{ matrix.target }}

View File

@ -92,7 +92,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
@ -152,7 +152,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
@ -206,6 +206,9 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
@ -221,11 +224,11 @@ jobs:
type=sha type=sha
- -
name: Build name: Build
uses: docker/bake-action@v6 uses: docker/bake-action@v5
with: with:
files: | files: |
./docker-bake.hcl ./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file }} ${{ steps.meta.outputs.bake-file }}
targets: build targets: build
``` ```
@ -268,12 +271,29 @@ similar to the previous one:
```yaml ```yaml
- -
name: Build name: Build
uses: docker/bake-action@v6 uses: docker/bake-action@v5
with: with:
files: | files: |
./docker-bake.hcl ./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file-tags }} ${{ steps.meta.outputs.bake-file-tags }}
cwd://${{ steps.meta.outputs.bake-file-labels }} ${{ steps.meta.outputs.bake-file-labels }}
targets: build
```
If you're building a [remote Bake definition](https://docs.docker.com/build/bake/remote-definition/)
using a [Git context](https://github.com/docker/bake-action?tab=readme-ov-file#git-context),
you must specify the location of the metadata-only bake file using a `cwd://`
prefix:
```yaml
-
name: Build
uses: docker/bake-action@v5
with:
source: "${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}"
files: |
./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file }}
targets: build targets: build
``` ```
@ -333,7 +353,7 @@ Alternatively, each output is also exported as an environment variable:
So it can be used with our [Docker Build Push action](https://github.com/docker/build-push-action/): So it can be used with our [Docker Build Push action](https://github.com/docker/build-push-action/):
```yaml ```yaml
- uses: docker/build-push-action@v6 - uses: docker/build-push-action@v5
with: with:
build-args: | build-args: |
DOCKER_METADATA_OUTPUT_JSON DOCKER_METADATA_OUTPUT_JSON
@ -925,7 +945,7 @@ that you can reuse them further in your workflow using the [`fromJSON` function]
images: name/app images: name/app
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v5
with: with:
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
@ -972,7 +992,7 @@ of the `metadata-action`:
images: name/app images: name/app
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v5
with: with:
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }} annotations: ${{ steps.meta.outputs.annotations }}
@ -988,12 +1008,12 @@ The same can be done with the [`bake-action`](https://github.com/docker/bake-act
images: name/app images: name/app
- -
name: Build name: Build
uses: docker/bake-action@v6 uses: docker/bake-action@v5
with: with:
files: | files: |
./docker-bake.hcl ./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file-tags }} ${{ steps.meta.outputs.bake-file-tags }}
cwd://${{ steps.meta.outputs.bake-file-annotations }} ${{ steps.meta.outputs.bake-file-annotations }}
targets: build targets: build
``` ```
@ -1019,7 +1039,7 @@ Please consult the documentation of your registry.
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v5
with: with:
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }} annotations: ${{ steps.meta.outputs.annotations }}

View File

@ -1,9 +1,3 @@
target "_common" {
args = {
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
}
}
group "default" { group "default" {
targets = ["build"] targets = ["build"]
} }
@ -17,49 +11,42 @@ group "validate" {
} }
target "build" { target "build" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "build-update" target = "build-update"
output = ["."] output = ["."]
} }
target "build-validate" { target "build-validate" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "build-validate" target = "build-validate"
output = ["type=cacheonly"] output = ["type=cacheonly"]
} }
target "format" { target "format" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "format-update" target = "format-update"
output = ["."] output = ["."]
} }
target "lint" { target "lint" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "lint" target = "lint"
output = ["type=cacheonly"] output = ["type=cacheonly"]
} }
target "vendor" { target "vendor" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "vendor-update" target = "vendor-update"
output = ["."] output = ["."]
} }
target "vendor-validate" { target "vendor-validate" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "vendor-validate" target = "vendor-validate"
output = ["type=cacheonly"] output = ["type=cacheonly"]
} }
target "test" { target "test" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "test-coverage" target = "test-coverage"
output = ["./coverage"] output = ["./coverage"]