mirror of
https://github.com/docker/bake-action.git
synced 2026-06-05 17:48:40 +02:00
Compare commits
207 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3acf805d94 | |||
| f6376ff6a4 | |||
| 60b3af61bc | |||
| f08ef55f78 | |||
| c22b3482ed | |||
| 40bffc195e | |||
| d7a0b5eb51 | |||
| 3965f4baf4 | |||
| 3d864c34f9 | |||
| 3589b0c183 | |||
| 2215fae6ab | |||
| d0cb9774dc | |||
| a6c0a91e79 | |||
| 74cb41d332 | |||
| 8f035c08cd | |||
| a4c28defc8 | |||
| d260a27f75 | |||
| 5efdf4de8d | |||
| 1a42865db7 | |||
| ba406cd72e | |||
| 1d0c0ffa52 | |||
| 68cf998b48 | |||
| 7a78e75fa4 | |||
| 24d8c3471c | |||
| 6de75d5ad2 | |||
| 72003b9fac | |||
| a1257e6518 | |||
| 846dea0f3a | |||
| 1367d98caa | |||
| 88f3e5553b | |||
| d576212e5b | |||
| d4a3c3cc87 | |||
| 37816e7475 | |||
| f5304128f3 | |||
| 4318518141 | |||
| 0dc934281a | |||
| 64a5bce7a2 | |||
| 212c367396 | |||
| d1ecc3a41e | |||
| ae6e8fe892 | |||
| 57dcb4dec4 | |||
| 76f9fa3a75 | |||
| 1c2b73661c | |||
| c38fbc0209 | |||
| 9d4c4c70ed | |||
| ab9ee171b4 | |||
| f252d74606 | |||
| 656e858067 | |||
| fdcf61eb1a | |||
| a17047c36c | |||
| 1b9d00da59 | |||
| 8f9e95c9aa | |||
| f7a0604619 | |||
| 4ba453fbc2 | |||
| be887ed69b | |||
| c9725ed6bb | |||
| c1f157cf76 | |||
| 28af3ee8ff | |||
| 4f08b22a19 | |||
| 5c5be5f8ee | |||
| c48383c7fd | |||
| 7bff531c65 | |||
| 4eb699fd94 | |||
| 3310620efe | |||
| 60f5d53310 | |||
| cb84b96ea2 | |||
| 63a0b90c7c | |||
| 5dd4f8e2d6 | |||
| 8342e4814b | |||
| 4e1bb14d4e | |||
| 5a1b7c9786 | |||
| a23a0ceb07 | |||
| 932b78563b | |||
| ded8f8f101 | |||
| d0cc8f345a | |||
| 8afe15ffcc | |||
| 77f4fc97b7 | |||
| bf35764d1d | |||
| 309da7d154 | |||
| 23cff4f49a | |||
| 5ca506d06f | |||
| da6b67e5ed | |||
| 23b87ebfd8 | |||
| f26d1f2c48 | |||
| 3ba2682456 | |||
| d2bf1df12d | |||
| 1677316f88 | |||
| 3fc70e1131 | |||
| f4c177e5d8 | |||
| fb23aa081d | |||
| 4434628f52 | |||
| 289179a60f | |||
| 52e5f5611a | |||
| 95dd0c6749 | |||
| ef35aaaf8b | |||
| a6f037366a | |||
| b6652aadd5 | |||
| fa9f3f5ac7 | |||
| 4c0e3cda9d | |||
| 3883a2154a | |||
| b8df42cc60 | |||
| 9bc07af8a8 | |||
| aeaa6df54c | |||
| 63fc7d13b7 | |||
| fd17cd07cd | |||
| d2a866bfbd | |||
| 1417204e8d | |||
| ef43224233 | |||
| d38ec1b2d6 | |||
| 782be980da | |||
| 51e939be13 | |||
| d5f33222b6 | |||
| 2e3d19baed | |||
| 22815eb8f2 | |||
| c24ab5d426 | |||
| 64673bcfac | |||
| f05b0ee234 | |||
| 6161d12436 | |||
| e626c7390c | |||
| 7e8997e58f | |||
| 9a9d8805d1 | |||
| cdf7e1c5cb | |||
| 01036657a2 | |||
| 76cc8060bd | |||
| 4cfe868c6e | |||
| fa256f8a0c | |||
| 8cea75c238 | |||
| a7cc98928a | |||
| 1b8b2f2b02 | |||
| 955c005d87 | |||
| 4c694667c2 | |||
| bc6f04190c | |||
| 5c57af45fc | |||
| 28c6eb5bfc | |||
| d52034e958 | |||
| 108b34f686 | |||
| af918ef258 | |||
| 1fe547e208 | |||
| 3e6a9c6a82 | |||
| a4d7f0b5b9 | |||
| 1877a04777 | |||
| 6ebd058199 | |||
| eac74531aa | |||
| 4eefc485ba | |||
| b7875ab9fc | |||
| f28b24308f | |||
| ad6ed14e0e | |||
| 93ee8f4f3f | |||
| dbdf67d511 | |||
| 16551d969e | |||
| bfc525280a | |||
| 216ea56fab | |||
| eb0e46e01a | |||
| e14760bd9a | |||
| bc6d272b50 | |||
| c0fe07dad6 | |||
| 9a5de0e159 | |||
| b5bad96092 | |||
| 09e9b54ae9 | |||
| 03ad189f86 | |||
| 3934de3594 | |||
| 2b6f83c616 | |||
| 40a4ea9523 | |||
| b976ed0e11 | |||
| 5060c11b60 | |||
| b0a0aeab0e | |||
| 39fbf35758 | |||
| ff7b24e385 | |||
| fd05574f2b | |||
| 7b24a43e4b | |||
| 10abbd2569 | |||
| 332466b809 | |||
| 867da3c872 | |||
| a06e6ea6d8 | |||
| b4514235a2 | |||
| 455cb06a8b | |||
| 95d04aff03 | |||
| ec3e762834 | |||
| f6acc70fe0 | |||
| f38226533a | |||
| 7e3fb815c2 | |||
| 297b5d570e | |||
| 11ce049f92 | |||
| 47185531a6 | |||
| 1c5f18a523 | |||
| 24721f62e7 | |||
| 7e57eefa1c | |||
| f36da5f84f | |||
| f81e4c23c9 | |||
| 6460b33ba7 | |||
| bc3c21b237 | |||
| 93d1f86e62 | |||
| 00f0c171f7 | |||
| a29d7e9cb9 | |||
| f40a782c97 | |||
| bc96707098 | |||
| 84cc400131 | |||
| 0160c64311 | |||
| 25ba9228c1 | |||
| 69497d5717 | |||
| 2def0425f4 | |||
| 1f186e91c9 | |||
| 8473a36b83 | |||
| bd980ca3d9 | |||
| 1a92fbfaa9 | |||
| 670407c68a | |||
| 4f5d587adf |
Binary file not shown.
|
After Width: | Height: | Size: 253 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -25,37 +25,112 @@ on:
|
|||||||
- 'test/**'
|
- 'test/**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
list-targets-group:
|
list-targets:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
-
|
||||||
|
testdir: group
|
||||||
|
expected: >
|
||||||
|
["t1","t2"]
|
||||||
|
-
|
||||||
|
testdir: group-matrix
|
||||||
|
target: validate
|
||||||
|
expected: >
|
||||||
|
["lint-default","lint-labs","lint-nydus","lint-proto","lint-yaml","validate-doctoc","validate-vendor"]
|
||||||
|
-
|
||||||
|
testdir: multi-files
|
||||||
|
files: |
|
||||||
|
docker-bake.json
|
||||||
|
docker-bake.hcl
|
||||||
|
expected: >
|
||||||
|
["v1-tag","v2-tag"]
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Matrix gen
|
name: Matrix gen
|
||||||
id: gen
|
id: gen
|
||||||
uses: ./subaction/list-targets
|
uses: ./subaction/list-targets
|
||||||
with:
|
with:
|
||||||
workdir: ./test/group
|
workdir: ./test/${{ matrix.testdir }}
|
||||||
|
files: ${{ matrix.files }}
|
||||||
|
target: ${{ matrix.target }}
|
||||||
-
|
-
|
||||||
name: Show matrix
|
name: Check output
|
||||||
run: |
|
uses: actions/github-script@v7
|
||||||
echo matrix=${{ steps.gen.outputs.matrix }}
|
env:
|
||||||
|
INPUT_TARGETS: ${{ steps.gen.outputs.targets }}
|
||||||
|
INPUT_EXPECTED: ${{ matrix.expected }}
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const targets = JSON.stringify(JSON.parse(core.getInput('targets')));
|
||||||
|
const expected = JSON.stringify(JSON.parse(core.getInput('expected')));
|
||||||
|
if (targets !== expected) {
|
||||||
|
throw new Error(`Targets do not match expected values: ${targets} != ${expected}`);
|
||||||
|
} else {
|
||||||
|
core.info(`✅`);
|
||||||
|
}
|
||||||
|
|
||||||
list-targets-group-matrix:
|
matrix:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
-
|
||||||
|
testdir: group
|
||||||
|
expected: >
|
||||||
|
[{"target":"t1"},{"target":"t2"}]
|
||||||
|
-
|
||||||
|
testdir: group-matrix
|
||||||
|
target: validate
|
||||||
|
expected: >
|
||||||
|
[{"target":"lint-default"},{"target":"lint-labs"},{"target":"lint-nydus"},{"target":"lint-proto"},{"target":"lint-yaml"},{"target":"validate-doctoc"},{"target":"validate-vendor"}]
|
||||||
|
-
|
||||||
|
testdir: group-with-platform
|
||||||
|
target: validate
|
||||||
|
expected: >
|
||||||
|
[{"target":"lint"},{"target":"lint-gopls"},{"target":"validate-docs"},{"target":"validate-vendor"}]
|
||||||
|
-
|
||||||
|
testdir: group-with-platform
|
||||||
|
target: validate
|
||||||
|
fields: platforms
|
||||||
|
expected: >
|
||||||
|
[{"target":"lint","platforms":"darwin/amd64"},{"target":"lint","platforms":"darwin/arm64"},{"target":"lint","platforms":"linux/amd64"},{"target":"lint","platforms":"linux/arm64"},{"target":"lint","platforms":"linux/s390x"},{"target":"lint","platforms":"linux/ppc64le"},{"target":"lint","platforms":"linux/riscv64"},{"target":"lint","platforms":"windows/amd64"},{"target":"lint","platforms":"windows/arm64"},{"target":"lint-gopls","platforms":"darwin/amd64"},{"target":"lint-gopls","platforms":"darwin/arm64"},{"target":"lint-gopls","platforms":"linux/amd64"},{"target":"lint-gopls","platforms":"linux/arm64"},{"target":"lint-gopls","platforms":"linux/s390x"},{"target":"lint-gopls","platforms":"linux/ppc64le"},{"target":"lint-gopls","platforms":"linux/riscv64"},{"target":"lint-gopls","platforms":"windows/amd64"},{"target":"lint-gopls","platforms":"windows/arm64"},{"target":"validate-docs"},{"target":"validate-vendor"}]
|
||||||
|
-
|
||||||
|
testdir: group-with-platform
|
||||||
|
target: validate
|
||||||
|
fields: platforms,dockerfile
|
||||||
|
expected: >
|
||||||
|
[{"target":"lint","dockerfile":"./hack/dockerfiles/lint.Dockerfile"},{"target":"lint","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"darwin/amd64"},{"target":"lint","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"darwin/arm64"},{"target":"lint","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"linux/amd64"},{"target":"lint","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"linux/arm64"},{"target":"lint","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"linux/s390x"},{"target":"lint","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"linux/ppc64le"},{"target":"lint","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"linux/riscv64"},{"target":"lint","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"windows/amd64"},{"target":"lint","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"windows/arm64"},{"target":"lint-gopls","dockerfile":"./hack/dockerfiles/lint.Dockerfile"},{"target":"lint-gopls","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"darwin/amd64"},{"target":"lint-gopls","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"darwin/arm64"},{"target":"lint-gopls","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"linux/amd64"},{"target":"lint-gopls","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"linux/arm64"},{"target":"lint-gopls","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"linux/s390x"},{"target":"lint-gopls","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"linux/ppc64le"},{"target":"lint-gopls","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"linux/riscv64"},{"target":"lint-gopls","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"windows/amd64"},{"target":"lint-gopls","dockerfile":"./hack/dockerfiles/lint.Dockerfile","platforms":"windows/arm64"},{"target":"validate-docs","dockerfile":"./hack/dockerfiles/docs.Dockerfile"},{"target":"validate-vendor","dockerfile":"./hack/dockerfiles/vendor.Dockerfile"}]
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Matrix gen
|
name: Matrix gen
|
||||||
id: gen
|
id: gen
|
||||||
uses: ./subaction/list-targets
|
uses: ./subaction/matrix
|
||||||
with:
|
with:
|
||||||
workdir: ./test/group-matrix
|
workdir: ./test/${{ matrix.testdir }}
|
||||||
target: validate
|
target: ${{ matrix.target }}
|
||||||
|
fields: ${{ matrix.fields }}
|
||||||
-
|
-
|
||||||
name: Show matrix
|
name: Check output
|
||||||
run: |
|
uses: actions/github-script@v7
|
||||||
echo matrix=${{ steps.gen.outputs.matrix }}
|
env:
|
||||||
|
INPUT_MATRIX: ${{ steps.gen.outputs.matrix }}
|
||||||
|
INPUT_EXPECTED: ${{ matrix.expected }}
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const matrix = JSON.stringify(JSON.parse(core.getInput('matrix')));
|
||||||
|
const expected = JSON.stringify(JSON.parse(core.getInput('expected')));
|
||||||
|
if (matrix !== expected) {
|
||||||
|
throw new Error(`Matrix do not match expected values: ${matrix} != ${expected}`);
|
||||||
|
} else {
|
||||||
|
core.info(`✅`);
|
||||||
|
}
|
||||||
|
|||||||
+368
-23
@@ -32,8 +32,8 @@ on:
|
|||||||
- 'subaction/**'
|
- 'subaction/**'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
BUILDX_VERSION: latest
|
BUILDX_VERSION: edge
|
||||||
BUILDKIT_IMAGE: moby/buildkit:buildx-stable-1
|
BUILDKIT_IMAGE: moby/buildkit:latest
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
bake:
|
bake:
|
||||||
@@ -52,7 +52,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
@@ -69,6 +69,7 @@ jobs:
|
|||||||
name: Build and push
|
name: Build and push
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
source: .
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
@@ -81,12 +82,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
source: .
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
set: |
|
set: |
|
||||||
@@ -97,7 +99,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Stop docker
|
name: Stop docker
|
||||||
run: |
|
run: |
|
||||||
@@ -108,12 +110,12 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
source: .
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
-
|
-
|
||||||
name: Check
|
name: Check
|
||||||
run: |
|
run: |
|
||||||
echo "${{ toJson(steps.bake) }}"
|
|
||||||
if [ "${{ steps.bake.outcome }}" != "failure" ] || [ "${{ steps.bake.conclusion }}" != "success" ]; then
|
if [ "${{ steps.bake.outcome }}" != "failure" ] || [ "${{ steps.bake.conclusion }}" != "success" ]; then
|
||||||
echo "::error::Should have failed"
|
echo "::error::Should have failed"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -124,7 +126,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Uninstall docker cli
|
name: Uninstall docker cli
|
||||||
run: |
|
run: |
|
||||||
@@ -144,15 +146,16 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
source: .
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
|
|
||||||
source:
|
remote:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -174,7 +177,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -188,6 +191,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
workdir: ./test/go
|
workdir: ./test/go
|
||||||
|
source: .
|
||||||
targets: binary
|
targets: binary
|
||||||
provenance: ${{ matrix.attrs }}
|
provenance: ${{ matrix.attrs }}
|
||||||
set: |
|
set: |
|
||||||
@@ -215,7 +219,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -229,6 +233,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
workdir: ./test/go
|
workdir: ./test/go
|
||||||
|
source: .
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
sbom: true
|
sbom: true
|
||||||
set: |
|
set: |
|
||||||
@@ -269,12 +274,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
workdir: ./test/go
|
workdir: ./test/go
|
||||||
|
source: .
|
||||||
set: |
|
set: |
|
||||||
*.platform=linux/amd64
|
*.platform=linux/amd64
|
||||||
*.output=type=image,"name=localhost:5000/name/app:v1.0.0,localhost:5000/name/app:latest",push=true
|
*.output=type=image,"name=localhost:5000/name/app:v1.0.0,localhost:5000/name/app:latest",push=true
|
||||||
@@ -290,7 +296,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -304,6 +310,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
workdir: ./test/group
|
workdir: ./test/group
|
||||||
|
source: .
|
||||||
push: true
|
push: true
|
||||||
set: |
|
set: |
|
||||||
t1.tags=localhost:5000/name/app:t1
|
t1.tags=localhost:5000/name/app:t1
|
||||||
@@ -314,7 +321,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Set malformed docker config
|
name: Set malformed docker config
|
||||||
run: |
|
run: |
|
||||||
@@ -324,6 +331,7 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
source: .
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
|
|
||||||
@@ -342,7 +350,7 @@ jobs:
|
|||||||
curl --retry 5 --retry-all-errors --retry-delay 0 --connect-timeout 5 --proxy http://127.0.0.1:3128 -v --insecure --head https://www.google.com
|
curl --retry 5 --retry-all-errors --retry-delay 0 --connect-timeout 5 --proxy http://127.0.0.1:3128 -v --insecure --head https://www.google.com
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Set proxy config
|
name: Set proxy config
|
||||||
run: |
|
run: |
|
||||||
@@ -361,6 +369,7 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
source: .
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
targets: app-proxy
|
targets: app-proxy
|
||||||
@@ -380,7 +389,7 @@ jobs:
|
|||||||
curl --retry 5 --retry-all-errors --retry-delay 0 --connect-timeout 5 --proxy http://127.0.0.1:3128 -v --insecure --head https://www.google.com
|
curl --retry 5 --retry-all-errors --retry-delay 0 --connect-timeout 5 --proxy http://127.0.0.1:3128 -v --insecure --head https://www.google.com
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -396,6 +405,7 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
source: .
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
|
|
||||||
@@ -404,7 +414,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -415,15 +425,13 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
|
||||||
source: "{{defaultContext}}"
|
|
||||||
|
|
||||||
git-context-and-local:
|
git-context-and-local:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -439,7 +447,6 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: "{{defaultContext}}"
|
|
||||||
files: |
|
files: |
|
||||||
cwd://${{ steps.meta.outputs.bake-file }}
|
cwd://${{ steps.meta.outputs.bake-file }}
|
||||||
|
|
||||||
@@ -453,7 +460,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -466,6 +473,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
workdir: ./test/go
|
workdir: ./test/go
|
||||||
|
source: .
|
||||||
set: |
|
set: |
|
||||||
*.output=type=image,name=localhost:5000/name/app:latest,push=true
|
*.output=type=image,name=localhost:5000/name/app:latest,push=true
|
||||||
*.output=type=docker,name=app:local
|
*.output=type=docker,name=app:local
|
||||||
@@ -496,7 +504,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -509,6 +517,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
workdir: ./test/go
|
workdir: ./test/go
|
||||||
|
source: .
|
||||||
targets: image
|
targets: image
|
||||||
load: true
|
load: true
|
||||||
push: true
|
push: true
|
||||||
@@ -522,3 +531,339 @@ jobs:
|
|||||||
name: Check docker
|
name: Check docker
|
||||||
run: |
|
run: |
|
||||||
docker image inspect localhost:5000/name/app:latest
|
docker image inspect localhost:5000/name/app:latest
|
||||||
|
|
||||||
|
summary-disable:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
./test/config.hcl
|
||||||
|
targets: app
|
||||||
|
env:
|
||||||
|
DOCKER_BUILD_SUMMARY: false
|
||||||
|
|
||||||
|
summary-disable-deprecated:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
source: .
|
||||||
|
files: |
|
||||||
|
./test/config.hcl
|
||||||
|
targets: app
|
||||||
|
env:
|
||||||
|
DOCKER_BUILD_NO_SUMMARY: true
|
||||||
|
|
||||||
|
summary-not-supported:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: v0.12.1
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
./test/config.hcl
|
||||||
|
targets: app
|
||||||
|
|
||||||
|
record-upload-disable:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
./test/config.hcl
|
||||||
|
targets: app
|
||||||
|
env:
|
||||||
|
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||||
|
|
||||||
|
record-retention-days:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
days:
|
||||||
|
- 2
|
||||||
|
- 0
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
./test/config.hcl
|
||||||
|
targets: app
|
||||||
|
env:
|
||||||
|
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }}
|
||||||
|
|
||||||
|
export-legacy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
legacy:
|
||||||
|
- false
|
||||||
|
- true
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
./test/config.hcl
|
||||||
|
targets: app
|
||||||
|
env:
|
||||||
|
DOCKER_BUILD_EXPORT_LEGACY: ${{ matrix.legacy }}
|
||||||
|
|
||||||
|
checks:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
buildx-version:
|
||||||
|
- edge
|
||||||
|
- v0.14.1
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.buildx-version }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
workdir: ./test
|
||||||
|
source: .
|
||||||
|
files: |
|
||||||
|
./lint.hcl
|
||||||
|
|
||||||
|
annotations-disabled:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
workdir: ./test
|
||||||
|
source: .
|
||||||
|
files: |
|
||||||
|
./lint.hcl
|
||||||
|
env:
|
||||||
|
DOCKER_BUILD_CHECKS_ANNOTATIONS: false
|
||||||
|
|
||||||
|
allow:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
buildx-version:
|
||||||
|
- edge
|
||||||
|
- v0.19.0
|
||||||
|
- v0.18.0
|
||||||
|
- v0.17.1
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.buildx-version }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
./test/config.hcl
|
||||||
|
allow: network.host
|
||||||
|
targets: app-entitlements
|
||||||
|
|
||||||
|
no-default-attestations:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
source: .
|
||||||
|
files: |
|
||||||
|
./test/config.hcl
|
||||||
|
env:
|
||||||
|
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
|
||||||
|
|
||||||
|
call-check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
id: bake
|
||||||
|
continue-on-error: true
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
workdir: ./test
|
||||||
|
source: .
|
||||||
|
files: |
|
||||||
|
./lint.hcl
|
||||||
|
call: check
|
||||||
|
targets: lint
|
||||||
|
-
|
||||||
|
name: Check
|
||||||
|
run: |
|
||||||
|
if [ "${{ steps.bake.outcome }}" != "failure" ] || [ "${{ steps.bake.conclusion }}" != "success" ]; then
|
||||||
|
echo "::error::Should have failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
call-check-multi:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
id: bake
|
||||||
|
continue-on-error: true
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
workdir: ./test
|
||||||
|
source: .
|
||||||
|
files: |
|
||||||
|
./lint.hcl
|
||||||
|
call: check
|
||||||
|
-
|
||||||
|
name: Check
|
||||||
|
run: |
|
||||||
|
if [ "${{ steps.bake.outcome }}" != "failure" ] || [ "${{ steps.bake.conclusion }}" != "success" ]; then
|
||||||
|
echo "::error::Should have failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
call-check-nowarning:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
id: bake
|
||||||
|
continue-on-error: true
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
source: .
|
||||||
|
files: |
|
||||||
|
./test/config.hcl
|
||||||
|
call: check
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
name: pr-assign-author
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- reopened
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
uses: crazy-max/.github/.github/workflows/pr-assign-author.yml@1b673f36fad86812f538c1df9794904038a23cbf
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
name: publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
-
|
||||||
|
name: Publish
|
||||||
|
uses: actions/publish-immutable-action@v0.0.4
|
||||||
@@ -23,15 +23,16 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
uses: docker/bake-action@v4
|
uses: docker/bake-action@v6
|
||||||
with:
|
with:
|
||||||
|
source: .
|
||||||
targets: test
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@v4
|
uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
file: ./coverage/clover.xml
|
files: ./coverage/clover.xml
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: List targets
|
name: List targets
|
||||||
id: generate
|
id: generate
|
||||||
@@ -36,11 +36,8 @@ 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@v4
|
uses: docker/bake-action@v6
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
|
|||||||
-541
File diff suppressed because one or more lines are too long
+8
-4
@@ -1,3 +1,9 @@
|
|||||||
|
# https://yarnpkg.com/configuration/yarnrc
|
||||||
|
|
||||||
|
compressionLevel: mixed
|
||||||
|
enableGlobalCache: false
|
||||||
|
enableHardenedMode: true
|
||||||
|
|
||||||
logFilters:
|
logFilters:
|
||||||
- code: YN0013
|
- code: YN0013
|
||||||
level: discard
|
level: discard
|
||||||
@@ -5,9 +11,7 @@ logFilters:
|
|||||||
level: discard
|
level: discard
|
||||||
- code: YN0076
|
- code: YN0076
|
||||||
level: discard
|
level: discard
|
||||||
|
- code: YN0086
|
||||||
|
level: discard
|
||||||
|
|
||||||
nodeLinker: node-modules
|
nodeLinker: node-modules
|
||||||
|
|
||||||
plugins:
|
|
||||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
|
||||||
spec: "@yarnpkg/plugin-interactive-tools"
|
|
||||||
|
|||||||
@@ -14,95 +14,64 @@ as a high-level build command.
|
|||||||
___
|
___
|
||||||
|
|
||||||
* [Usage](#usage)
|
* [Usage](#usage)
|
||||||
* [Path context](#path-context)
|
|
||||||
* [Git context](#git-context)
|
* [Git context](#git-context)
|
||||||
|
* [Path context](#path-context)
|
||||||
|
* [Summaries](#summaries)
|
||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [outputs](#outputs)
|
* [outputs](#outputs)
|
||||||
|
* [environment variables](#environment-variables)
|
||||||
* [Subactions](#subactions)
|
* [Subactions](#subactions)
|
||||||
* [`list-targets`](#list-targets)
|
* [`matrix`](subaction/matrix)
|
||||||
* [Contributing](#contributing)
|
* [Contributing](#contributing)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Path context
|
|
||||||
|
|
||||||
By default, this action will use the local bake definition (`source: .`), so
|
|
||||||
you need to use the [`actions/checkout`](https://github.com/actions/checkout/)
|
|
||||||
action to check out the repository.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
bake:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/bake-action@v4
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
```
|
|
||||||
|
|
||||||
### Git context
|
### Git context
|
||||||
|
|
||||||
Git context can be provided using the [`source` input](#inputs). This means
|
Since `v6` this action uses the [Git context](https://docs.docker.com/build/bake/remote-definition/)
|
||||||
that you don't need to use the [`actions/checkout`](https://github.com/actions/checkout/)
|
to build from a remote bake definition by default like the [build-push-action](https://github.com/docker/build-push-action)
|
||||||
|
does. This means that you don't need to use the [`actions/checkout`](https://github.com/actions/checkout/)
|
||||||
action to check out the repository as [BuildKit](https://docs.docker.com/build/buildkit/)
|
action to check out the repository as [BuildKit](https://docs.docker.com/build/buildkit/)
|
||||||
will do this directly.
|
will do this directly.
|
||||||
|
|
||||||
|
The git reference will be based on the [event that triggered your workflow](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows)
|
||||||
|
and will result in the following context: `https://github.com/<owner>/<repo>.git#<ref>`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
bake:
|
bake:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/bake-action@v4
|
uses: docker/bake-action@v6
|
||||||
with:
|
with:
|
||||||
source: "${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}"
|
|
||||||
push: true
|
push: true
|
||||||
|
set: |
|
||||||
|
*.tags=user/app:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
Be careful because **any file mutation in the steps that precede the build step
|
Be careful because **any file mutation in the steps that precede the build step
|
||||||
will be ignored, including processing of the `.dockerignore` file** since
|
will be ignored, including processing of the `.dockerignore` file** since
|
||||||
the context is based on the Git reference. However, you can use the
|
the context is based on the Git reference. However, you can use the
|
||||||
[Path context](#path-context) alongside the [`actions/checkout`](https://github.com/actions/checkout/)
|
[Path context](#path-context) using the [`source` input](#inputs) alongside
|
||||||
action to remove this restriction.
|
the [`actions/checkout`](https://github.com/actions/checkout/) action to remove
|
||||||
|
this restriction.
|
||||||
|
|
||||||
Default Git context can also be provided using the [Handlebars template](https://handlebarsjs.com/guide/)
|
Default Git context can also be provided using the [Handlebars template](https://handlebarsjs.com/guide/)
|
||||||
expression `{{defaultContext}}`. Here we can use it to provide a subdirectory
|
expression `{{defaultContext}}`. Here we can use it to provide a subdirectory
|
||||||
@@ -111,10 +80,12 @@ to the default Git context:
|
|||||||
```yaml
|
```yaml
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/bake-action@v4
|
uses: docker/bake-action@v6
|
||||||
with:
|
with:
|
||||||
source: "{{defaultContext}}:mysubdir"
|
source: "{{defaultContext}}:mysubdir"
|
||||||
push: true
|
push: true
|
||||||
|
set: |
|
||||||
|
*.tags=user/app:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
Building from the current repository automatically uses the `GITHUB_TOKEN`
|
Building from the current repository automatically uses the `GITHUB_TOKEN`
|
||||||
@@ -129,14 +100,82 @@ another private repository for remote definitions, you can set the
|
|||||||
```yaml
|
```yaml
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/bake-action@v4
|
uses: docker/bake-action@v6
|
||||||
with:
|
with:
|
||||||
source: "${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}"
|
|
||||||
push: true
|
push: true
|
||||||
|
set: |
|
||||||
|
*.tags=user/app:latest
|
||||||
env:
|
env:
|
||||||
BUILDX_BAKE_GIT_AUTH_TOKEN: ${{ secrets.MYTOKEN }}
|
BUILDX_BAKE_GIT_AUTH_TOKEN: ${{ secrets.MYTOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Path context
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bake:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
uses: docker/bake-action@v6
|
||||||
|
with:
|
||||||
|
source: .
|
||||||
|
push: true
|
||||||
|
set: |
|
||||||
|
*.tags=user/app:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
## Summaries
|
||||||
|
|
||||||
|
This action generates a [job summary](https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/)
|
||||||
|
that provides a detailed overview of the build execution. The summary shows an
|
||||||
|
overview of all the steps executed during the build, including the build
|
||||||
|
inputs, bake definition, and eventual errors.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The summary also includes a link for downloading a build record archive with
|
||||||
|
additional details about the build execution for all the bake targets,
|
||||||
|
including build stats, logs, outputs, and more. The build record can be
|
||||||
|
imported to Docker Desktop for inspecting the build in greater detail.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
>
|
||||||
|
> If you're using the [`actions/download-artifact`](https://github.com/actions/download-artifact)
|
||||||
|
> action in your workflow, you need to ignore the build record artifacts
|
||||||
|
> if `name` and `pattern` inputs are not specified ([defaults to download all artifacts](https://github.com/actions/download-artifact?tab=readme-ov-file#download-all-artifacts) of the workflow),
|
||||||
|
> otherwise the action will fail:
|
||||||
|
> ```yaml
|
||||||
|
> - uses: actions/download-artifact@v4
|
||||||
|
> with:
|
||||||
|
> pattern: "!*.dockerbuild"
|
||||||
|
> ```
|
||||||
|
> More info: https://github.com/actions/toolkit/pull/1874
|
||||||
|
|
||||||
|
Summaries are enabled by default, but can be disabled with the
|
||||||
|
`DOCKER_BUILD_SUMMARY` [environment variable](#environment-variables).
|
||||||
|
|
||||||
|
For more information about summaries, refer to the
|
||||||
|
[documentation](https://docs.docker.com/go/build-summary/).
|
||||||
|
|
||||||
## Customizing
|
## Customizing
|
||||||
|
|
||||||
### inputs
|
### inputs
|
||||||
@@ -161,17 +200,19 @@ The following inputs can be used as `step.with` keys
|
|||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
|----------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|----------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
|
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
|
||||||
| `source` | String | Context to build from. Can be either local (`.`) or a [remote bake definition](https://docs.docker.com/build/customize/bake/file-definition/#remote-definition) |
|
|
||||||
| `files` | List/CSV | List of [bake definition files](https://docs.docker.com/build/customize/bake/file-definition/) |
|
|
||||||
| `workdir` | String | Working directory of execution |
|
| `workdir` | String | Working directory of execution |
|
||||||
| `targets` | List/CSV | List of bake targets (`default` target used if empty) |
|
| `source` | String | Context to build from. Can be either local (`.`) or a [remote bake definition](https://docs.docker.com/build/bake/remote-definition/) |
|
||||||
|
| `allow` | List/CSV | Allow build to access specified resources (e.g., `network.host`) |
|
||||||
|
| `call` | String | Set method for evaluating build (e.g., check) |
|
||||||
|
| `files` | List/CSV | List of [bake definition files](https://docs.docker.com/build/customize/bake/file-definition/) |
|
||||||
| `no-cache` | Bool | Do not use cache when building the image (default `false`) |
|
| `no-cache` | Bool | Do not use cache when building the image (default `false`) |
|
||||||
| `pull` | Bool | Always attempt to pull a newer version of the image (default `false`) |
|
| `pull` | Bool | Always attempt to pull a newer version of the image (default `false`) |
|
||||||
| `load` | Bool | Load is a shorthand for `--set=*.output=type=docker` (default `false`) |
|
| `load` | Bool | Load is a shorthand for `--set=*.output=type=docker` (default `false`) |
|
||||||
| `provenance` | Bool/String | [Provenance](https://docs.docker.com/build/attestations/slsa-provenance/) is a shorthand for `--set=*.attest=type=provenance` |
|
| `provenance` | Bool/String | [Provenance](https://docs.docker.com/build/attestations/slsa-provenance/) is a shorthand for `--set=*.attest=type=provenance` |
|
||||||
| `push` | Bool | Push is a shorthand for `--set=*.output=type=registry` (default `false`) |
|
| `push` | Bool | Push is a shorthand for `--set=*.output=type=registry` (default `false`) |
|
||||||
| `sbom` | Bool/String | [SBOM](https://docs.docker.com/build/attestations/sbom/) is a shorthand for `--set=*.attest=type=sbom` |
|
| `sbom` | Bool/String | [SBOM](https://docs.docker.com/build/attestations/sbom/) is a shorthand for `--set=*.attest=type=sbom` |
|
||||||
| `set` | List | List of [targets values to override](https://docs.docker.com/engine/reference/commandline/buildx_bake/#set) (eg: `targetpattern.key=value`) |
|
| `set` | List | List of [targets values to override](https://docs.docker.com/engine/reference/commandline/buildx_bake/#set) (e.g., `targetpattern.key=value`) |
|
||||||
|
| `targets` | List/CSV | List of bake targets (`default` target used if empty) |
|
||||||
| `github-token` | String | API token used to authenticate to a Git repository for [remote definitions](https://docs.docker.com/build/bake/remote-definition/) (default `${{ github.token }}`) |
|
| `github-token` | String | API token used to authenticate to a Git repository for [remote definitions](https://docs.docker.com/build/bake/remote-definition/) (default `${{ github.token }}`) |
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
@@ -182,78 +223,19 @@ The following outputs are available
|
|||||||
|------------|------|-----------------------|
|
|------------|------|-----------------------|
|
||||||
| `metadata` | JSON | Build result metadata |
|
| `metadata` | JSON | Build result metadata |
|
||||||
|
|
||||||
|
### environment variables
|
||||||
|
|
||||||
|
| Name | Type | Default | Description |
|
||||||
|
|--------------------------------------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| `DOCKER_BUILD_CHECKS_ANNOTATIONS` | Bool | `true` | If `false`, GitHub annotations are not generated for [build checks](https://docs.docker.com/build/checks/) |
|
||||||
|
| `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation is disabled |
|
||||||
|
| `DOCKER_BUILD_RECORD_UPLOAD` | Bool | `true` | If `false`, build record upload as [GitHub artifact](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts) is disabled |
|
||||||
|
| `DOCKER_BUILD_RECORD_RETENTION_DAYS` | Number | | Duration after which build record artifact will expire in days. Defaults to repository/org [retention settings](https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#artifact-and-log-retention-policy) if unset or `0` |
|
||||||
|
| `DOCKER_BUILD_EXPORT_LEGACY` | Bool | `false` | If `true`, exports build using legacy export-build tool instead of [`buildx history export` command](https://docs.docker.com/reference/cli/docker/buildx/history/export/) |
|
||||||
|
|
||||||
## Subactions
|
## Subactions
|
||||||
|
|
||||||
### `list-targets`
|
* [`matrix`](subaction/matrix)
|
||||||
|
|
||||||
This subaction generates a list of Bake targets that can be used in a [GitHub matrix](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix),
|
|
||||||
so you can distribute your builds across multiple runners.
|
|
||||||
|
|
||||||
```hcl
|
|
||||||
# docker-bake.hcl
|
|
||||||
group "validate" {
|
|
||||||
targets = ["lint", "doctoc"]
|
|
||||||
}
|
|
||||||
|
|
||||||
target "lint" {
|
|
||||||
target = "lint"
|
|
||||||
}
|
|
||||||
|
|
||||||
target "doctoc" {
|
|
||||||
target = "doctoc"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
prepare:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
targets: ${{ steps.generate.outputs.targets }}
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
-
|
|
||||||
name: List targets
|
|
||||||
id: generate
|
|
||||||
uses: docker/bake-action/subaction/list-targets@v4
|
|
||||||
with:
|
|
||||||
target: validate
|
|
||||||
|
|
||||||
validate:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs:
|
|
||||||
- prepare
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
target: ${{ fromJson(needs.prepare.outputs.targets) }}
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
-
|
|
||||||
name: Validate
|
|
||||||
uses: docker/bake-action@v4
|
|
||||||
with:
|
|
||||||
targets: ${{ matrix.target }}
|
|
||||||
```
|
|
||||||
#### inputs
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
|--------------|-------------|---------------------------------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| `workdir` | String | Working directory to use (defaults to `.`) |
|
|
||||||
| `files` | List/CSV | List of [bake definition files](https://docs.docker.com/build/customize/bake/file-definition/) |
|
|
||||||
| `target` | String | The target to use within the bake file |
|
|
||||||
|
|
||||||
#### outputs
|
|
||||||
|
|
||||||
The following outputs are available
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
|------------|----------|----------------------------|
|
|
||||||
| `targets` | List/CSV | List of extracted targest |
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|||||||
+109
-21
@@ -1,4 +1,4 @@
|
|||||||
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
import {afterEach, beforeEach, describe, expect, jest, test} from '@jest/globals';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
@@ -122,6 +122,7 @@ jest.spyOn(Bake.prototype, 'getDefinition').mockImplementation(async (): Promise
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('getArgs', () => {
|
describe('getArgs', () => {
|
||||||
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env = Object.keys(process.env).reduce((object, key) => {
|
process.env = Object.keys(process.env).reduce((object, key) => {
|
||||||
if (!key.startsWith('INPUT_')) {
|
if (!key.startsWith('INPUT_')) {
|
||||||
@@ -130,6 +131,9 @@ describe('getArgs', () => {
|
|||||||
return object;
|
return object;
|
||||||
}, {});
|
}, {});
|
||||||
});
|
});
|
||||||
|
afterEach(() => {
|
||||||
|
process.env = originalEnv;
|
||||||
|
});
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each([
|
test.each([
|
||||||
@@ -137,6 +141,7 @@ describe('getArgs', () => {
|
|||||||
0,
|
0,
|
||||||
'0.4.1',
|
'0.4.1',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
@@ -144,12 +149,14 @@ describe('getArgs', () => {
|
|||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
1,
|
1,
|
||||||
'0.8.2',
|
'0.8.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
@@ -158,12 +165,14 @@ describe('getArgs', () => {
|
|||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson
|
'--metadata-file', metadataJson
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
2,
|
2,
|
||||||
'0.8.2',
|
'0.8.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
['targets', 'webapp\nvalidate'],
|
['targets', 'webapp\nvalidate'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
@@ -174,12 +183,14 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
'webapp', 'validate'
|
'webapp', 'validate'
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
3,
|
3,
|
||||||
'0.8.2',
|
'0.8.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
['set', '*.cache-from=type=gha\n*.cache-to=type=gha'],
|
['set', '*.cache-from=type=gha\n*.cache-to=type=gha'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
@@ -191,12 +202,14 @@ describe('getArgs', () => {
|
|||||||
'--set', '*.cache-from=type=gha',
|
'--set', '*.cache-from=type=gha',
|
||||||
'--set', '*.cache-to=type=gha',
|
'--set', '*.cache-to=type=gha',
|
||||||
'--metadata-file', metadataJson
|
'--metadata-file', metadataJson
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
4,
|
4,
|
||||||
'0.10.0',
|
'0.10.0',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
@@ -205,13 +218,15 @@ describe('getArgs', () => {
|
|||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
"--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
5,
|
5,
|
||||||
'0.10.0',
|
'0.10.0',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
@@ -221,13 +236,15 @@ describe('getArgs', () => {
|
|||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", `builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`
|
"--provenance", `builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
6,
|
6,
|
||||||
'0.10.0',
|
'0.10.0',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
@@ -237,13 +254,15 @@ describe('getArgs', () => {
|
|||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", `mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`
|
"--provenance", `mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
7,
|
7,
|
||||||
'0.10.0',
|
'0.10.0',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
@@ -254,12 +273,14 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", 'false'
|
"--provenance", 'false'
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
8,
|
8,
|
||||||
'0.10.0',
|
'0.10.0',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
@@ -270,12 +291,14 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", 'builder-id=foo'
|
"--provenance", 'builder-id=foo'
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
9,
|
9,
|
||||||
'0.10.0',
|
'0.10.0',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
@@ -288,14 +311,16 @@ describe('getArgs', () => {
|
|||||||
'--set', '*.platform=linux/amd64,linux/ppc64le,linux/s390x',
|
'--set', '*.platform=linux/amd64,linux/ppc64le,linux/s390x',
|
||||||
'--set', `*.output=type=image,"name=moby/buildkit:v0.11.0,moby/buildkit:latest",push=true`,
|
'--set', `*.output=type=image,"name=moby/buildkit:v0.11.0,moby/buildkit:latest",push=true`,
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
'image-all'
|
'image-all'
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
10,
|
10,
|
||||||
'0.10.0',
|
'0.10.0',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
@@ -307,15 +332,15 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--set', `*.labels.foo=bar=#baz`,
|
'--set', `*.labels.foo=bar=#baz`,
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
'image-all'
|
'image-all'
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
11,
|
11,
|
||||||
'0.10.0',
|
'0.10.0',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['source', '{{defaultContext}}'],
|
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
@@ -327,12 +352,75 @@ describe('getArgs', () => {
|
|||||||
'https://github.com/docker/build-push-action.git#refs/heads/master',
|
'https://github.com/docker/build-push-action.git#refs/heads/master',
|
||||||
'--file', './foo.hcl',
|
'--file', './foo.hcl',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
|
],
|
||||||
|
[
|
||||||
|
12,
|
||||||
|
'0.17.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
|
['allow', 'network.host'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'bake',
|
||||||
|
'--allow', 'network.host',
|
||||||
|
'--metadata-file', metadataJson,
|
||||||
|
"--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`
|
||||||
|
],
|
||||||
|
undefined
|
||||||
|
],
|
||||||
|
[
|
||||||
|
13,
|
||||||
|
'0.15.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['source', '{{defaultContext}}:subdir'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
['files', './foo.hcl'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'bake',
|
||||||
|
'https://github.com/docker/build-push-action.git#refs/heads/master:subdir',
|
||||||
|
'--file', './foo.hcl',
|
||||||
|
'--metadata-file', metadataJson,
|
||||||
|
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
|
],
|
||||||
|
undefined
|
||||||
|
],
|
||||||
|
[
|
||||||
|
14,
|
||||||
|
'0.15.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['source', '.'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false']
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'bake',
|
||||||
|
'--metadata-file', metadataJson
|
||||||
|
],
|
||||||
|
new Map<string, string>([
|
||||||
|
['BUILDX_NO_DEFAULT_ATTESTATIONS', '1']
|
||||||
|
])
|
||||||
],
|
],
|
||||||
])(
|
])(
|
||||||
'[%d] given %p with %p as inputs, returns %p',
|
'[%d] given %p with %p as inputs, returns %p',
|
||||||
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {
|
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>, envs: Map<string, string> | undefined) => {
|
||||||
|
if (envs) {
|
||||||
|
envs.forEach((value: string, name: string) => {
|
||||||
|
process.env[name] = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
inputs.forEach((value: string, name: string) => {
|
inputs.forEach((value: string, name: string) => {
|
||||||
setInput(name, value);
|
setInput(name, value);
|
||||||
});
|
});
|
||||||
|
|||||||
+14
-8
@@ -10,18 +10,21 @@ inputs:
|
|||||||
builder:
|
builder:
|
||||||
description: "Builder instance"
|
description: "Builder instance"
|
||||||
required: false
|
required: false
|
||||||
source:
|
|
||||||
description: "Context to build from. Can be either local or a remote bake definition"
|
|
||||||
required: false
|
|
||||||
files:
|
|
||||||
description: "List of bake definition files"
|
|
||||||
required: false
|
|
||||||
workdir:
|
workdir:
|
||||||
description: "Working directory of bake execution"
|
description: "Working directory of bake execution"
|
||||||
required: false
|
required: false
|
||||||
default: '.'
|
default: '.'
|
||||||
targets:
|
source:
|
||||||
description: "List of bake targets"
|
description: "Context to build from. Can be either local or a remote bake definition"
|
||||||
|
required: false
|
||||||
|
allow:
|
||||||
|
description: "Allow build to access specified resources (e.g., network.host)"
|
||||||
|
required: false
|
||||||
|
call:
|
||||||
|
description: "Set method for evaluating build (e.g., check)"
|
||||||
|
required: false
|
||||||
|
files:
|
||||||
|
description: "List of bake definition files"
|
||||||
required: false
|
required: false
|
||||||
no-cache:
|
no-cache:
|
||||||
description: "Do not use cache when building the image"
|
description: "Do not use cache when building the image"
|
||||||
@@ -48,6 +51,9 @@ inputs:
|
|||||||
set:
|
set:
|
||||||
description: "List of targets values to override (eg. targetpattern.key=value)"
|
description: "List of targets values to override (eg. targetpattern.key=value)"
|
||||||
required: false
|
required: false
|
||||||
|
targets:
|
||||||
|
description: "List of bake targets"
|
||||||
|
required: false
|
||||||
github-token:
|
github-token:
|
||||||
description: "API token used to authenticate to a Git repository for remote definitions"
|
description: "API token used to authenticate to a Git repository for remote definitions"
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
|||||||
+19
-18
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+24
-6
@@ -2358,9 +2358,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|||||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
dot-object
|
|
||||||
MIT
|
|
||||||
|
|
||||||
encoding
|
encoding
|
||||||
MIT
|
MIT
|
||||||
Copyright (c) 2012-2014 Andris Reinman
|
Copyright (c) 2012-2014 Andris Reinman
|
||||||
@@ -2516,6 +2513,30 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
he
|
||||||
|
MIT
|
||||||
|
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
iconv-lite
|
iconv-lite
|
||||||
MIT
|
MIT
|
||||||
Copyright (c) 2011 Alexander Shtuchkin
|
Copyright (c) 2011 Alexander Shtuchkin
|
||||||
@@ -3667,9 +3688,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
twirp-ts
|
|
||||||
MIT
|
|
||||||
|
|
||||||
undici
|
undici
|
||||||
MIT
|
MIT
|
||||||
MIT License
|
MIT License
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,3 +1,9 @@
|
|||||||
|
target "_common" {
|
||||||
|
args = {
|
||||||
|
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
group "default" {
|
group "default" {
|
||||||
targets = ["build"]
|
targets = ["build"]
|
||||||
}
|
}
|
||||||
@@ -11,42 +17,49 @@ 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"]
|
||||||
|
|||||||
+14
-14
@@ -24,25 +24,25 @@
|
|||||||
],
|
],
|
||||||
"author": "Docker Inc.",
|
"author": "Docker Inc.",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"packageManager": "yarn@3.6.3",
|
"packageManager": "yarn@4.9.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@docker/actions-toolkit": "^0.24.0",
|
"@docker/actions-toolkit": "^0.63.0",
|
||||||
"handlebars": "^4.7.8"
|
"handlebars": "^4.7.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.12.12",
|
"@types/node": "^20.19.9",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||||
"@typescript-eslint/parser": "^7.9.0",
|
"@typescript-eslint/parser": "^7.18.0",
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.3",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.1",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.2",
|
||||||
"eslint-plugin-jest": "^28.5.0",
|
"eslint-plugin-jest": "^28.14.0",
|
||||||
"eslint-plugin-prettier": "^5.1.3",
|
"eslint-plugin-prettier": "^5.5.4",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.6.2",
|
||||||
"ts-jest": "^29.1.2",
|
"ts-jest": "^29.4.1",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.4.5"
|
"typescript": "^5.9.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-7
@@ -12,9 +12,11 @@ import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
|||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
builder: string;
|
builder: string;
|
||||||
files: string[];
|
|
||||||
workdir: string;
|
workdir: string;
|
||||||
targets: string[];
|
source: string;
|
||||||
|
allow: string[];
|
||||||
|
call: string;
|
||||||
|
files: string[];
|
||||||
'no-cache': boolean;
|
'no-cache': boolean;
|
||||||
pull: boolean;
|
pull: boolean;
|
||||||
load: boolean;
|
load: boolean;
|
||||||
@@ -22,16 +24,18 @@ export interface Inputs {
|
|||||||
push: boolean;
|
push: boolean;
|
||||||
sbom: string;
|
sbom: string;
|
||||||
set: string[];
|
set: string[];
|
||||||
source: string;
|
targets: string[];
|
||||||
'github-token': string;
|
'github-token': string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getInputs(): Promise<Inputs> {
|
export async function getInputs(): Promise<Inputs> {
|
||||||
return {
|
return {
|
||||||
builder: core.getInput('builder'),
|
builder: core.getInput('builder'),
|
||||||
files: Util.getInputList('files'),
|
|
||||||
workdir: core.getInput('workdir') || '.',
|
workdir: core.getInput('workdir') || '.',
|
||||||
targets: Util.getInputList('targets'),
|
source: getSourceInput('source'),
|
||||||
|
allow: Util.getInputList('allow'),
|
||||||
|
call: core.getInput('call'),
|
||||||
|
files: Util.getInputList('files'),
|
||||||
'no-cache': core.getBooleanInput('no-cache'),
|
'no-cache': core.getBooleanInput('no-cache'),
|
||||||
pull: core.getBooleanInput('pull'),
|
pull: core.getBooleanInput('pull'),
|
||||||
load: core.getBooleanInput('load'),
|
load: core.getBooleanInput('load'),
|
||||||
@@ -39,7 +43,7 @@ export async function getInputs(): Promise<Inputs> {
|
|||||||
push: core.getBooleanInput('push'),
|
push: core.getBooleanInput('push'),
|
||||||
sbom: core.getInput('sbom'),
|
sbom: core.getInput('sbom'),
|
||||||
set: Util.getInputList('set', {ignoreComma: true, quote: false}),
|
set: Util.getInputList('set', {ignoreComma: true, quote: false}),
|
||||||
source: getSourceInput('source'),
|
targets: Util.getInputList('targets'),
|
||||||
'github-token': core.getInput('github-token')
|
'github-token': core.getInput('github-token')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -58,6 +62,21 @@ async function getBakeArgs(inputs: Inputs, definition: BakeDefinition, toolkit:
|
|||||||
if (inputs.source) {
|
if (inputs.source) {
|
||||||
args.push(inputs.source);
|
args.push(inputs.source);
|
||||||
}
|
}
|
||||||
|
if (await toolkit.buildx.versionSatisfies('>=0.17.0')) {
|
||||||
|
if (await toolkit.buildx.versionSatisfies('>=0.18.0')) {
|
||||||
|
// allow filesystem entitlements by default
|
||||||
|
inputs.allow.push('fs=*');
|
||||||
|
}
|
||||||
|
await Util.asyncForEach(inputs.allow, async allow => {
|
||||||
|
args.push('--allow', allow);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (inputs.call) {
|
||||||
|
if (!(await toolkit.buildx.versionSatisfies('>=0.16.0'))) {
|
||||||
|
throw new Error(`Buildx >= 0.16.0 is required to use the call flag.`);
|
||||||
|
}
|
||||||
|
args.push('--call', inputs.call);
|
||||||
|
}
|
||||||
await Util.asyncForEach(inputs.files, async file => {
|
await Util.asyncForEach(inputs.files, async file => {
|
||||||
args.push('--file', file);
|
args.push('--file', file);
|
||||||
});
|
});
|
||||||
@@ -70,7 +89,7 @@ async function getBakeArgs(inputs: Inputs, definition: BakeDefinition, toolkit:
|
|||||||
if (await toolkit.buildx.versionSatisfies('>=0.10.0')) {
|
if (await toolkit.buildx.versionSatisfies('>=0.10.0')) {
|
||||||
if (inputs.provenance) {
|
if (inputs.provenance) {
|
||||||
args.push('--provenance', inputs.provenance);
|
args.push('--provenance', inputs.provenance);
|
||||||
} else if ((await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !Bake.hasDockerExporter(definition, inputs.load)) {
|
} else if (!noDefaultAttestations() && (await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !Bake.hasDockerExporter(definition, inputs.load)) {
|
||||||
// if provenance not specified and BuildKit version compatible for
|
// if provenance not specified and BuildKit version compatible for
|
||||||
// attestation, set default provenance. Also needs to make sure user
|
// attestation, set default provenance. Also needs to make sure user
|
||||||
// doesn't want to explicitly load the image to docker.
|
// doesn't want to explicitly load the image to docker.
|
||||||
@@ -114,8 +133,18 @@ function getSourceInput(name: string): string {
|
|||||||
let source = handlebars.compile(core.getInput(name))({
|
let source = handlebars.compile(core.getInput(name))({
|
||||||
defaultContext: Context.gitContext()
|
defaultContext: Context.gitContext()
|
||||||
});
|
});
|
||||||
|
if (!source) {
|
||||||
|
source = Context.gitContext();
|
||||||
|
}
|
||||||
if (source === '.') {
|
if (source === '.') {
|
||||||
source = '';
|
source = '';
|
||||||
}
|
}
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function noDefaultAttestations(): boolean {
|
||||||
|
if (process.env.BUILDX_NO_DEFAULT_ATTESTATIONS) {
|
||||||
|
return Util.parseBool(process.env.BUILDX_NO_DEFAULT_ATTESTATIONS);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
+206
-6
@@ -3,14 +3,19 @@ import * as path from 'path';
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as actionsToolkit from '@docker/actions-toolkit';
|
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||||
|
|
||||||
|
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
|
||||||
|
import {History as BuildxHistory} from '@docker/actions-toolkit/lib/buildx/history';
|
||||||
import {Context} from '@docker/actions-toolkit/lib/context';
|
import {Context} from '@docker/actions-toolkit/lib/context';
|
||||||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||||
import {Exec} from '@docker/actions-toolkit/lib/exec';
|
import {Exec} from '@docker/actions-toolkit/lib/exec';
|
||||||
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||||
|
import {Util} from '@docker/actions-toolkit/lib/util';
|
||||||
|
|
||||||
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
||||||
|
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder';
|
||||||
import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker';
|
import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker';
|
||||||
|
import {UploadArtifactResponse} from '@docker/actions-toolkit/lib/types/github';
|
||||||
|
|
||||||
import * as context from './context';
|
import * as context from './context';
|
||||||
import * as stateHelper from './state-helper';
|
import * as stateHelper from './state-helper';
|
||||||
@@ -18,7 +23,12 @@ import * as stateHelper from './state-helper';
|
|||||||
actionsToolkit.run(
|
actionsToolkit.run(
|
||||||
// main
|
// main
|
||||||
async () => {
|
async () => {
|
||||||
|
const startedTime = new Date();
|
||||||
|
|
||||||
const inputs: context.Inputs = await context.getInputs();
|
const inputs: context.Inputs = await context.getInputs();
|
||||||
|
stateHelper.setSummaryInputs(inputs);
|
||||||
|
core.debug(`inputs: ${JSON.stringify(inputs)}`);
|
||||||
|
|
||||||
const toolkit = new Toolkit();
|
const toolkit = new Toolkit();
|
||||||
const gitAuthToken = process.env.BUILDX_BAKE_GIT_AUTH_TOKEN ?? inputs['github-token'];
|
const gitAuthToken = process.env.BUILDX_BAKE_GIT_AUTH_TOKEN ?? inputs['github-token'];
|
||||||
|
|
||||||
@@ -75,8 +85,11 @@ actionsToolkit.run(
|
|||||||
await toolkit.buildx.printVersion();
|
await toolkit.buildx.printVersion();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let builder: BuilderInfo;
|
||||||
await core.group(`Builder info`, async () => {
|
await core.group(`Builder info`, async () => {
|
||||||
const builder = await toolkit.builder.inspect(inputs.builder);
|
builder = await toolkit.builder.inspect(inputs.builder);
|
||||||
|
stateHelper.setBuilderDriver(builder.driver ?? '');
|
||||||
|
stateHelper.setBuilderEndpoint(builder.nodes?.[0]?.endpoint ?? '');
|
||||||
core.info(JSON.stringify(builder, null, 2));
|
core.info(JSON.stringify(builder, null, 2));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -84,6 +97,7 @@ actionsToolkit.run(
|
|||||||
await core.group(`Parsing raw definition`, async () => {
|
await core.group(`Parsing raw definition`, async () => {
|
||||||
definition = await toolkit.buildxBake.getDefinition(
|
definition = await toolkit.buildxBake.getDefinition(
|
||||||
{
|
{
|
||||||
|
allow: inputs.allow,
|
||||||
files: inputs.files,
|
files: inputs.files,
|
||||||
load: inputs.load,
|
load: inputs.load,
|
||||||
noCache: inputs['no-cache'],
|
noCache: inputs['no-cache'],
|
||||||
@@ -103,29 +117,55 @@ actionsToolkit.run(
|
|||||||
if (!definition) {
|
if (!definition) {
|
||||||
throw new Error('Bake definition not set');
|
throw new Error('Bake definition not set');
|
||||||
}
|
}
|
||||||
|
stateHelper.setBakeDefinition(definition);
|
||||||
|
|
||||||
const args: string[] = await context.getArgs(inputs, definition, toolkit);
|
const args: string[] = await context.getArgs(inputs, definition, toolkit);
|
||||||
const buildCmd = await toolkit.buildx.getCommand(args);
|
const buildCmd = await toolkit.buildx.getCommand(args);
|
||||||
const buildEnv = Object.assign({}, process.env, {
|
const buildEnv = Object.assign({}, process.env, {
|
||||||
BUILDX_BAKE_GIT_AUTH_TOKEN: gitAuthToken
|
BUILDX_BAKE_GIT_AUTH_TOKEN: gitAuthToken,
|
||||||
|
BUILDX_METADATA_WARNINGS: 'true'
|
||||||
}) as {
|
}) as {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
await core.group(`Bake definition`, async () => {
|
await core.group(`Bake definition`, async () => {
|
||||||
await Exec.exec(buildCmd.command, [...buildCmd.args, '--print'], {
|
await Exec.getExecOutput(buildCmd.command, [...buildCmd.args, '--print'], {
|
||||||
cwd: inputs.workdir,
|
cwd: inputs.workdir,
|
||||||
env: buildEnv
|
env: buildEnv,
|
||||||
|
ignoreReturnCode: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw Error(res.stderr);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let err: Error | undefined;
|
||||||
await Exec.getExecOutput(buildCmd.command, buildCmd.args, {
|
await Exec.getExecOutput(buildCmd.command, buildCmd.args, {
|
||||||
cwd: inputs.workdir,
|
cwd: inputs.workdir,
|
||||||
env: buildEnv,
|
env: buildEnv,
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.exitCode != 0) {
|
||||||
throw new Error(`buildx bake failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
if (inputs.call && inputs.call === 'check' && res.stdout.length > 0) {
|
||||||
|
// checks warnings are printed to stdout: https://github.com/docker/buildx/pull/2647
|
||||||
|
// with bake we can have multiple targets being checked so we need to
|
||||||
|
// count the total number of warnings
|
||||||
|
const totalWarnings = [...res.stdout.matchAll(/^Check complete, (\d+) warnings? (?:has|have) been found!/gm)].reduce((sum, m) => sum + parseInt(m[1], 10), 0);
|
||||||
|
if (totalWarnings > 0) {
|
||||||
|
// https://github.com/docker/buildx/blob/1e50e8ddabe108f009b9925e13a321d7c8f99f26/commands/build.go#L797-L803
|
||||||
|
if (totalWarnings === 1) {
|
||||||
|
err = Error(`Check complete, ${totalWarnings} warning has been found!`);
|
||||||
|
} else {
|
||||||
|
err = Error(`Check complete, ${totalWarnings} warnings have been found!`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// if there are no warnings found, return the first line of stdout
|
||||||
|
err = Error(res.stdout.split('\n')[0]?.trim());
|
||||||
|
}
|
||||||
|
} else if (res.stderr.length > 0) {
|
||||||
|
err = Error(`buildx bake failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -137,9 +177,96 @@ actionsToolkit.run(
|
|||||||
core.setOutput('metadata', metadatadt);
|
core.setOutput('metadata', metadatadt);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let refs: Array<string> = [];
|
||||||
|
await core.group(`Build references`, async () => {
|
||||||
|
refs = await buildRefs(toolkit, startedTime, inputs.builder);
|
||||||
|
if (refs.length > 0) {
|
||||||
|
for (const ref of refs) {
|
||||||
|
core.info(ref);
|
||||||
|
}
|
||||||
|
stateHelper.setBuildRefs(refs);
|
||||||
|
} else {
|
||||||
|
core.info('No build references found');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (buildChecksAnnotationsEnabled()) {
|
||||||
|
const warnings = toolkit.buildxBake.resolveWarnings(metadata);
|
||||||
|
if (refs.length > 0 && warnings && warnings.length > 0) {
|
||||||
|
const annotations = await Buildx.convertWarningsToGitHubAnnotations(warnings, refs);
|
||||||
|
core.debug(`annotations: ${JSON.stringify(annotations, null, 2)}`);
|
||||||
|
if (annotations && annotations.length > 0) {
|
||||||
|
await core.group(`Generating GitHub annotations (${annotations.length} build checks found)`, async () => {
|
||||||
|
for (const annotation of annotations) {
|
||||||
|
core.warning(annotation.message, annotation);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await core.group(`Check build summary support`, async () => {
|
||||||
|
if (!buildSummaryEnabled()) {
|
||||||
|
core.info('Build summary disabled');
|
||||||
|
} else if (inputs.call && inputs.call !== 'build') {
|
||||||
|
core.info(`Build summary skipped for ${inputs.call} subrequest`);
|
||||||
|
} else if (GitHub.isGHES) {
|
||||||
|
core.info('Build summary is not yet supported on GHES');
|
||||||
|
} else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) {
|
||||||
|
core.info('Build summary requires Buildx >= 0.13.0');
|
||||||
|
} else if (refs.length == 0) {
|
||||||
|
core.info('Build summary requires at least one build reference');
|
||||||
|
} else {
|
||||||
|
core.info('Build summary supported!');
|
||||||
|
stateHelper.setSummarySupported();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// post
|
// post
|
||||||
async () => {
|
async () => {
|
||||||
|
if (stateHelper.isSummarySupported) {
|
||||||
|
await core.group(`Generating build summary`, async () => {
|
||||||
|
try {
|
||||||
|
const recordUploadEnabled = buildRecordUploadEnabled();
|
||||||
|
let recordRetentionDays: number | undefined;
|
||||||
|
if (recordUploadEnabled) {
|
||||||
|
recordRetentionDays = buildRecordRetentionDays();
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildxHistory = new BuildxHistory();
|
||||||
|
const exportRes = await buildxHistory.export({
|
||||||
|
refs: stateHelper.buildRefs,
|
||||||
|
useContainer: buildExportLegacy()
|
||||||
|
});
|
||||||
|
core.info(`Build records written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
|
||||||
|
|
||||||
|
let uploadRes: UploadArtifactResponse | undefined;
|
||||||
|
if (recordUploadEnabled) {
|
||||||
|
uploadRes = await GitHub.uploadArtifact({
|
||||||
|
filename: exportRes.dockerbuildFilename,
|
||||||
|
mimeType: 'application/gzip',
|
||||||
|
retentionDays: recordRetentionDays
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await GitHub.writeBuildSummary({
|
||||||
|
exportRes: exportRes,
|
||||||
|
uploadRes: uploadRes,
|
||||||
|
inputs: stateHelper.summaryInputs,
|
||||||
|
bakeDefinition: stateHelper.bakeDefinition,
|
||||||
|
driver: stateHelper.builderDriver,
|
||||||
|
endpoint: stateHelper.builderEndpoint
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
core.warning(e.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
if (stateHelper.tmpDir.length > 0) {
|
if (stateHelper.tmpDir.length > 0) {
|
||||||
await core.group(`Removing temp folder ${stateHelper.tmpDir}`, async () => {
|
await core.group(`Removing temp folder ${stateHelper.tmpDir}`, async () => {
|
||||||
fs.rmSync(stateHelper.tmpDir, {recursive: true});
|
fs.rmSync(stateHelper.tmpDir, {recursive: true});
|
||||||
@@ -147,3 +274,76 @@ actionsToolkit.run(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
async function buildRefs(toolkit: Toolkit, since: Date, builder?: string): Promise<Array<string>> {
|
||||||
|
// get refs from metadata file
|
||||||
|
const metaRefs = toolkit.buildxBake.resolveRefs();
|
||||||
|
if (metaRefs) {
|
||||||
|
return metaRefs;
|
||||||
|
}
|
||||||
|
// otherwise, look for the very first build ref since the build has started
|
||||||
|
if (!builder) {
|
||||||
|
const currentBuilder = await toolkit.builder.inspect();
|
||||||
|
builder = currentBuilder.name;
|
||||||
|
}
|
||||||
|
const res = Buildx.refs({
|
||||||
|
dir: Buildx.refsDir,
|
||||||
|
builderName: builder,
|
||||||
|
since: since
|
||||||
|
});
|
||||||
|
const refs: Array<string> = [];
|
||||||
|
for (const ref in res) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(res, ref)) {
|
||||||
|
refs.push(ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return refs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildChecksAnnotationsEnabled(): boolean {
|
||||||
|
if (process.env.DOCKER_BUILD_CHECKS_ANNOTATIONS) {
|
||||||
|
return Util.parseBool(process.env.DOCKER_BUILD_CHECKS_ANNOTATIONS);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildSummaryEnabled(): boolean {
|
||||||
|
if (process.env.DOCKER_BUILD_NO_SUMMARY) {
|
||||||
|
core.warning('DOCKER_BUILD_NO_SUMMARY is deprecated. Set DOCKER_BUILD_SUMMARY to false instead.');
|
||||||
|
return !Util.parseBool(process.env.DOCKER_BUILD_NO_SUMMARY);
|
||||||
|
} else if (process.env.DOCKER_BUILD_SUMMARY) {
|
||||||
|
return Util.parseBool(process.env.DOCKER_BUILD_SUMMARY);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildRecordUploadEnabled(): boolean {
|
||||||
|
if (process.env.DOCKER_BUILD_RECORD_UPLOAD) {
|
||||||
|
return Util.parseBool(process.env.DOCKER_BUILD_RECORD_UPLOAD);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildRecordRetentionDays(): number | undefined {
|
||||||
|
let val: string | undefined;
|
||||||
|
if (process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS) {
|
||||||
|
core.warning('DOCKER_BUILD_EXPORT_RETENTION_DAYS is deprecated. Use DOCKER_BUILD_RECORD_RETENTION_DAYS instead.');
|
||||||
|
val = process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS;
|
||||||
|
} else if (process.env.DOCKER_BUILD_RECORD_RETENTION_DAYS) {
|
||||||
|
val = process.env.DOCKER_BUILD_RECORD_RETENTION_DAYS;
|
||||||
|
}
|
||||||
|
if (val) {
|
||||||
|
const res = parseInt(val);
|
||||||
|
if (isNaN(res)) {
|
||||||
|
throw Error(`Invalid build record retention days: ${val}`);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildExportLegacy(): boolean {
|
||||||
|
if (process.env.DOCKER_BUILD_EXPORT_LEGACY) {
|
||||||
|
return Util.parseBool(process.env.DOCKER_BUILD_EXPORT_LEGACY);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,58 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
|
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
||||||
|
|
||||||
|
import {Inputs} from './context';
|
||||||
|
|
||||||
export const tmpDir = process.env['STATE_tmpDir'] || '';
|
export const tmpDir = process.env['STATE_tmpDir'] || '';
|
||||||
|
|
||||||
|
export const builderDriver = process.env['STATE_builderDriver'] || '';
|
||||||
|
export const builderEndpoint = process.env['STATE_builderEndpoint'] || '';
|
||||||
|
export const summaryInputs = process.env['STATE_summaryInputs'] ? JSON.parse(process.env['STATE_summaryInputs']) : undefined;
|
||||||
|
export const bakeDefinition = process.env['STATE_bakeDefinition'] ? <BakeDefinition>JSON.parse(process.env['STATE_bakeDefinition']) : undefined;
|
||||||
|
|
||||||
|
export const buildRefs = process.env['STATE_buildRefs'] ? process.env['STATE_buildRefs'].split(',') : [];
|
||||||
|
export const isSummarySupported = !!process.env['STATE_isSummarySupported'];
|
||||||
|
|
||||||
export function setTmpDir(tmpDir: string) {
|
export function setTmpDir(tmpDir: string) {
|
||||||
core.saveState('tmpDir', tmpDir);
|
core.saveState('tmpDir', tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setBuilderDriver(builderDriver: string) {
|
||||||
|
core.saveState('builderDriver', builderDriver);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setBuilderEndpoint(builderEndpoint: string) {
|
||||||
|
core.saveState('builderEndpoint', builderEndpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setBakeDefinition(bakeDefinition: BakeDefinition) {
|
||||||
|
core.saveState('bakeDefinition', JSON.stringify(bakeDefinition));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setBuildRefs(buildRefs: Array<string>) {
|
||||||
|
core.saveState('buildRefs', buildRefs.join(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setSummarySupported() {
|
||||||
|
core.saveState('isSummarySupported', 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setSummaryInputs(inputs: Inputs) {
|
||||||
|
const res = {};
|
||||||
|
for (const key of Object.keys(inputs)) {
|
||||||
|
if (key === 'github-token') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const value: string | string[] | boolean = inputs[key];
|
||||||
|
if (typeof value === 'boolean' && !value) {
|
||||||
|
continue;
|
||||||
|
} else if (Array.isArray(value) && value.length === 0) {
|
||||||
|
continue;
|
||||||
|
} else if (!value) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
res[key] = value;
|
||||||
|
}
|
||||||
|
core.saveState('summaryInputs', JSON.stringify(res));
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
> [!WARNING]
|
||||||
|
> `docker/bake-action/subaction/list-targets` is deprecated and will be removed
|
||||||
|
> in a future release. Please use [`docker/bake-action/subaction/matrix`](../matrix)
|
||||||
|
> instead.
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
This subaction generates a list of Bake targets that can be used in a [GitHub matrix](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix),
|
||||||
|
so you can distribute your builds across multiple runners.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
* [Usage](#usage)
|
||||||
|
* [Customizing](#customizing)
|
||||||
|
* [inputs](#inputs)
|
||||||
|
* [outputs](#outputs)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
# docker-bake.hcl
|
||||||
|
group "validate" {
|
||||||
|
targets = ["lint", "doctoc"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "lint" {
|
||||||
|
target = "lint"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "doctoc" {
|
||||||
|
target = "doctoc"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
prepare:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
targets: ${{ steps.generate.outputs.targets }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: List targets
|
||||||
|
id: generate
|
||||||
|
uses: docker/bake-action/subaction/list-targets@v6
|
||||||
|
with:
|
||||||
|
target: validate
|
||||||
|
|
||||||
|
validate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
target: ${{ fromJson(needs.prepare.outputs.targets) }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Validate
|
||||||
|
uses: docker/bake-action@v6
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target }}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Customizing
|
||||||
|
|
||||||
|
### inputs
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
|--------------|-------------|---------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| `workdir` | String | Working directory to use (defaults to `.`) |
|
||||||
|
| `files` | List/CSV | List of [bake definition files](https://docs.docker.com/build/customize/bake/file-definition/) |
|
||||||
|
| `target` | String | The target to use within the bake file |
|
||||||
|
|
||||||
|
### outputs
|
||||||
|
|
||||||
|
The following outputs are available
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
|------------|----------|---------------------------|
|
||||||
|
| `targets` | List/CSV | List of extracted targets |
|
||||||
@@ -26,12 +26,23 @@ runs:
|
|||||||
name: Generate
|
name: Generate
|
||||||
id: generate
|
id: generate
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
|
env:
|
||||||
|
INPUT_WORKDIR: ${{ inputs.workdir }}
|
||||||
|
INPUT_FILES: ${{ inputs.files }}
|
||||||
|
INPUT_TARGET: ${{ inputs.target }}
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
let def;
|
core.warning(`docker/bake-action/subaction/list-targets is deprecated and will be removed in a future release. Please use docker/bake-action/subaction/matrix instead.`);
|
||||||
const files = `${{ inputs.files }}` ? `${{ inputs.files }}`.split(',') : [];
|
|
||||||
const target = `${{ inputs.target }}`;
|
|
||||||
|
|
||||||
|
function getInputList(name) {
|
||||||
|
return core.getInput(name) ? core.getInput(name).split(/[\r?\n,]+/).filter(x => x !== '') : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const workdir = core.getInput('workdir');
|
||||||
|
const files = getInputList('files');
|
||||||
|
const target = core.getInput('target');
|
||||||
|
|
||||||
|
let def = {};
|
||||||
await core.group(`Validating definition`, async () => {
|
await core.group(`Validating definition`, async () => {
|
||||||
let args = ['buildx', 'bake'];
|
let args = ['buildx', 'bake'];
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
@@ -45,7 +56,7 @@ runs:
|
|||||||
const res = await exec.getExecOutput('docker', args, {
|
const res = await exec.getExecOutput('docker', args, {
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
silent: true,
|
silent: true,
|
||||||
cwd: `${{ inputs.workdir }}`
|
cwd: workdir
|
||||||
});
|
});
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
|
|||||||
@@ -0,0 +1,140 @@
|
|||||||
|
## About
|
||||||
|
|
||||||
|
This subaction generates a multi-dimension matrix that can be used in a [GitHub matrix](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix)
|
||||||
|
through the [`include` property](https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow#expanding-or-adding-matrix-configurations)
|
||||||
|
so you can distribute your builds across multiple runners.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
* [Usage](#usage)
|
||||||
|
* [Customizing](#customizing)
|
||||||
|
* [inputs](#inputs)
|
||||||
|
* [outputs](#outputs)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### List targets
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
# docker-bake.hcl
|
||||||
|
group "validate" {
|
||||||
|
targets = ["lint", "doctoc"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "lint" {
|
||||||
|
target = "lint"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "doctoc" {
|
||||||
|
target = "doctoc"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
prepare:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.generate.outputs.matrix }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Generate matrix
|
||||||
|
id: generate
|
||||||
|
uses: docker/bake-action/subaction/matrix@v6
|
||||||
|
with:
|
||||||
|
target: validate
|
||||||
|
|
||||||
|
validate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include: ${{ fromJson(needs.prepare.outputs.matrix) }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Validate
|
||||||
|
uses: docker/bake-action@v6
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target }}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Platforms split
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
# docker-bake.hcl
|
||||||
|
target "lint" {
|
||||||
|
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
|
||||||
|
output = ["type=cacheonly"]
|
||||||
|
platforms = [
|
||||||
|
"darwin/amd64",
|
||||||
|
"darwin/arm64",
|
||||||
|
"linux/amd64",
|
||||||
|
"linux/arm64",
|
||||||
|
"linux/s390x",
|
||||||
|
"linux/ppc64le",
|
||||||
|
"linux/riscv64",
|
||||||
|
"windows/amd64",
|
||||||
|
"windows/arm64"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
prepare:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.generate.outputs.matrix }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Generate matrix
|
||||||
|
id: generate
|
||||||
|
uses: docker/bake-action/subaction/matrix@v6
|
||||||
|
with:
|
||||||
|
target: lint
|
||||||
|
fields: platforms
|
||||||
|
|
||||||
|
lint:
|
||||||
|
runs-on: ${{ startsWith(matrix.platforms, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include: ${{ fromJson(needs.prepare.outputs.matrix) }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Lint
|
||||||
|
uses: docker/bake-action@v6
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target }}
|
||||||
|
set: |
|
||||||
|
*.platform=${{ matrix.platforms }}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Customizing
|
||||||
|
|
||||||
|
### inputs
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
|-----------|----------|------------------------------------------------------------------------------------------------|
|
||||||
|
| `workdir` | String | Working directory to use (defaults to `.`) |
|
||||||
|
| `files` | List/CSV | List of [bake definition files](https://docs.docker.com/build/customize/bake/file-definition/) |
|
||||||
|
| `target` | String | The target to use within the bake file |
|
||||||
|
| `fields` | String | List of extra fields to include in the matrix |
|
||||||
|
|
||||||
|
### outputs
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
|----------|------|----------------------|
|
||||||
|
| `matrix` | JSON | Matrix configuration |
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
|
||||||
|
name: 'Matrix'
|
||||||
|
description: 'Generate a matrix from a Bake definition to help distributing builds in your workflow'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
workdir:
|
||||||
|
description: Working directory
|
||||||
|
default: '.'
|
||||||
|
required: false
|
||||||
|
files:
|
||||||
|
description: List of Bake files
|
||||||
|
required: false
|
||||||
|
target:
|
||||||
|
description: Bake target
|
||||||
|
required: false
|
||||||
|
fields:
|
||||||
|
description: List of extra fields to include in the matrix
|
||||||
|
required: false
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
matrix:
|
||||||
|
description: Matrix configuration
|
||||||
|
value: ${{ steps.generate.outputs.includes }}
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Generate
|
||||||
|
id: generate
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
env:
|
||||||
|
INPUT_WORKDIR: ${{ inputs.workdir }}
|
||||||
|
INPUT_FILES: ${{ inputs.files }}
|
||||||
|
INPUT_TARGET: ${{ inputs.target }}
|
||||||
|
INPUT_FIELDS: ${{ inputs.fields }}
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
function getInputList(name) {
|
||||||
|
return core.getInput(name) ? core.getInput(name).split(/[\r?\n,]+/).filter(x => x !== '') : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const workdir = core.getInput('workdir');
|
||||||
|
const files = getInputList('files');
|
||||||
|
const target = core.getInput('target');
|
||||||
|
const fields = getInputList('fields');
|
||||||
|
|
||||||
|
let def = {};
|
||||||
|
await core.group(`Parsing definition`, async () => {
|
||||||
|
let args = ['buildx', 'bake'];
|
||||||
|
for (const file of files) {
|
||||||
|
args.push('--file', file);
|
||||||
|
}
|
||||||
|
if (target) {
|
||||||
|
args.push(target);
|
||||||
|
}
|
||||||
|
args.push('--print');
|
||||||
|
const res = await exec.getExecOutput('docker', args, {
|
||||||
|
ignoreReturnCode: true,
|
||||||
|
silent: true,
|
||||||
|
cwd: workdir
|
||||||
|
});
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr);
|
||||||
|
}
|
||||||
|
def = JSON.parse(res.stdout.trim());
|
||||||
|
core.info(JSON.stringify(def, null, 2));
|
||||||
|
});
|
||||||
|
|
||||||
|
await core.group(`Generating matrix`, async () => {
|
||||||
|
const result = [];
|
||||||
|
for (const targetName of Object.keys(def.target)) {
|
||||||
|
const target = def.target[targetName];
|
||||||
|
const entry = { target: targetName };
|
||||||
|
if (fields.length === 0) {
|
||||||
|
result.push({ ...entry });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let fieldFound = false;
|
||||||
|
Object.keys(target).forEach(field => {
|
||||||
|
if (fields.includes(field)) {
|
||||||
|
fieldFound = true;
|
||||||
|
const value = target[field];
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
value.forEach((v) => {
|
||||||
|
entry[field] = v;
|
||||||
|
result.push({ ...entry });
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
entry[field] = value;
|
||||||
|
result.push({ ...entry });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!fieldFound) {
|
||||||
|
result.push({ ...entry });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
core.info(JSON.stringify(result, null, 2));
|
||||||
|
core.setOutput('includes', JSON.stringify(result));
|
||||||
|
});
|
||||||
@@ -42,3 +42,8 @@ target "app-proxy" {
|
|||||||
inherits = ["app"]
|
inherits = ["app"]
|
||||||
dockerfile = "proxy.Dockerfile"
|
dockerfile = "proxy.Dockerfile"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target "app-entitlements" {
|
||||||
|
inherits = ["app"]
|
||||||
|
entitlements = ["network.host"]
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
group "validate" {
|
||||||
|
targets = ["lint", "lint-gopls", "validate-vendor", "validate-docs"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "lint" {
|
||||||
|
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
|
||||||
|
output = ["type=cacheonly"]
|
||||||
|
platforms = [
|
||||||
|
"darwin/amd64",
|
||||||
|
"darwin/arm64",
|
||||||
|
"linux/amd64",
|
||||||
|
"linux/arm64",
|
||||||
|
"linux/s390x",
|
||||||
|
"linux/ppc64le",
|
||||||
|
"linux/riscv64",
|
||||||
|
"windows/amd64",
|
||||||
|
"windows/arm64"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "lint-gopls" {
|
||||||
|
inherits = ["lint"]
|
||||||
|
target = "gopls-analyze"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "validate-vendor" {
|
||||||
|
dockerfile = "./hack/dockerfiles/vendor.Dockerfile"
|
||||||
|
target = "validate"
|
||||||
|
output = ["type=cacheonly"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "validate-docs" {
|
||||||
|
dockerfile = "./hack/dockerfiles/docs.Dockerfile"
|
||||||
|
target = "validate"
|
||||||
|
output = ["type=cacheonly"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
frOM busybox as base
|
||||||
|
cOpy lint-other.Dockerfile .
|
||||||
|
|
||||||
|
froM busybox aS notused
|
||||||
|
COPY lint-other.Dockerfile .
|
||||||
|
|
||||||
|
from scratch
|
||||||
|
COPy --from=base \
|
||||||
|
/lint-other.Dockerfile \
|
||||||
|
/
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
frOM busybox as base
|
||||||
|
cOpy lint.Dockerfile .
|
||||||
|
|
||||||
|
from scratch
|
||||||
|
MAINTAINER moby@example.com
|
||||||
|
COPy --from=base \
|
||||||
|
/lint.Dockerfile \
|
||||||
|
/
|
||||||
|
|
||||||
|
CMD [ "echo", "Hello, Norway!" ]
|
||||||
|
CMD [ "echo", "Hello, Sweden!" ]
|
||||||
|
ENTRYPOINT my-program start
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
group "default" {
|
||||||
|
targets = ["lint", "lint-other", "lint-inline"]
|
||||||
|
}
|
||||||
|
target "lint" {
|
||||||
|
dockerfile = "lint.Dockerfile"
|
||||||
|
}
|
||||||
|
target "lint-other" {
|
||||||
|
dockerfile = "lint-other.Dockerfile"
|
||||||
|
}
|
||||||
|
target "lint-inline" {
|
||||||
|
dockerfile-inline = "FRoM alpine\nENTRYPOINT [\"echo\", \"hello\"]"
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
group "default" {
|
||||||
|
targets = ["t3"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "t3" {
|
||||||
|
name = "${item.tag}"
|
||||||
|
matrix = {
|
||||||
|
item = t3
|
||||||
|
}
|
||||||
|
args = {
|
||||||
|
VERSION = "${item.version}"
|
||||||
|
DUMMY_ARG = "${item.arg}"
|
||||||
|
}
|
||||||
|
tags = ["${item.tag}"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"t3": [
|
||||||
|
{
|
||||||
|
"version": "v1",
|
||||||
|
"arg": "v1-value",
|
||||||
|
"tag": "v1-tag"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v2",
|
||||||
|
"arg": "v2-value",
|
||||||
|
"tag": "v2-tag"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user