mirror of
https://github.com/docker/bake-action.git
synced 2026-06-05 09:38:40 +02:00
Compare commits
70 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5be5f02ff8 | |||
| 4f25520e7a | |||
| eeacb3deff | |||
| cce027f633 | |||
| 53ce91f18b | |||
| 6b8437d2b5 | |||
| d14785b0cb | |||
| 597dc07998 | |||
| 8ba51ac4ee | |||
| 23c049fba9 | |||
| 41c10f2beb | |||
| 5b9bf92d49 | |||
| 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 |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 8.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -25,75 +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@v6
|
||||||
-
|
-
|
||||||
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: Check targets
|
name: Check output
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v8
|
||||||
|
env:
|
||||||
|
INPUT_TARGETS: ${{ steps.gen.outputs.targets }}
|
||||||
|
INPUT_EXPECTED: ${{ matrix.expected }}
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const targets = `${{ steps.gen.outputs.targets }}`;
|
const targets = JSON.stringify(JSON.parse(core.getInput('targets')));
|
||||||
if (!targets) {
|
const expected = JSON.stringify(JSON.parse(core.getInput('expected')));
|
||||||
core.setFailed('No targets generated');
|
if (targets !== expected) {
|
||||||
|
throw new Error(`Targets do not match expected values: ${targets} != ${expected}`);
|
||||||
|
} else {
|
||||||
|
core.info(`✅`);
|
||||||
}
|
}
|
||||||
core.info(`targets=${targets}`);
|
|
||||||
|
|
||||||
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@v6
|
||||||
-
|
-
|
||||||
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: Check targets
|
name: Check output
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v8
|
||||||
|
env:
|
||||||
|
INPUT_MATRIX: ${{ steps.gen.outputs.matrix }}
|
||||||
|
INPUT_EXPECTED: ${{ matrix.expected }}
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const targets = `${{ steps.gen.outputs.targets }}`;
|
const matrix = JSON.stringify(JSON.parse(core.getInput('matrix')));
|
||||||
if (!targets) {
|
const expected = JSON.stringify(JSON.parse(core.getInput('expected')));
|
||||||
core.setFailed('No targets generated');
|
if (matrix !== expected) {
|
||||||
|
throw new Error(`Matrix do not match expected values: ${matrix} != ${expected}`);
|
||||||
|
} else {
|
||||||
|
core.info(`✅`);
|
||||||
}
|
}
|
||||||
core.info(`targets=${targets}`);
|
|
||||||
|
|
||||||
list-targets-multi-files:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
-
|
|
||||||
name: Matrix gen
|
|
||||||
id: gen
|
|
||||||
uses: ./subaction/list-targets
|
|
||||||
with:
|
|
||||||
workdir: ./test/multi-files
|
|
||||||
files: |
|
|
||||||
docker-bake.json
|
|
||||||
docker-bake.hcl
|
|
||||||
-
|
|
||||||
name: Check targets
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const targets = `${{ steps.gen.outputs.targets }}`;
|
|
||||||
if (!targets) {
|
|
||||||
core.setFailed('No targets generated');
|
|
||||||
}
|
|
||||||
core.info(`targets=${targets}`);
|
|
||||||
|
|||||||
+183
-29
@@ -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@v6
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
@@ -82,7 +82,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -99,7 +99,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Stop docker
|
name: Stop docker
|
||||||
run: |
|
run: |
|
||||||
@@ -116,7 +116,6 @@ jobs:
|
|||||||
-
|
-
|
||||||
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
|
||||||
@@ -127,7 +126,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Uninstall docker cli
|
name: Uninstall docker cli
|
||||||
run: |
|
run: |
|
||||||
@@ -156,7 +155,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -178,7 +177,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -220,7 +219,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -275,7 +274,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -297,7 +296,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -322,7 +321,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set malformed docker config
|
name: Set malformed docker config
|
||||||
run: |
|
run: |
|
||||||
@@ -351,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@v6
|
||||||
-
|
-
|
||||||
name: Set proxy config
|
name: Set proxy config
|
||||||
run: |
|
run: |
|
||||||
@@ -390,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@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -415,7 +414,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -432,7 +431,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -461,7 +460,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -505,7 +504,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -538,7 +537,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -561,7 +560,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -585,7 +584,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -606,7 +605,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -635,7 +634,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -653,18 +652,47 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }}
|
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@v6
|
||||||
|
-
|
||||||
|
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:
|
checks:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
buildx-version:
|
buildx-version:
|
||||||
- latest
|
- edge
|
||||||
- v0.14.1
|
- v0.14.1
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -686,7 +714,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -711,13 +739,14 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
buildx-version:
|
buildx-version:
|
||||||
- v0.19.0-rc2
|
- edge
|
||||||
|
- v0.19.0
|
||||||
- v0.18.0
|
- v0.18.0
|
||||||
- v0.17.1
|
- v0.17.1
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -733,3 +762,128 @@ jobs:
|
|||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
allow: network.host
|
allow: network.host
|
||||||
targets: app-entitlements
|
targets: app-entitlements
|
||||||
|
|
||||||
|
no-default-attestations:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
-
|
||||||
|
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@v6
|
||||||
|
-
|
||||||
|
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@v6
|
||||||
|
-
|
||||||
|
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@v6
|
||||||
|
-
|
||||||
|
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
|
||||||
|
|
||||||
|
attest-override:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
-
|
||||||
|
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 and push
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
workdir: ./test/attest
|
||||||
|
source: .
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Publish
|
name: Publish
|
||||||
uses: actions/publish-immutable-action@v0.0.4
|
uses: actions/publish-immutable-action@v0.0.4
|
||||||
|
|||||||
@@ -21,10 +21,14 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
uses: docker/bake-action@v6
|
uses: docker/bake-action@v6
|
||||||
with:
|
with:
|
||||||
|
source: .
|
||||||
targets: test
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: List targets
|
name: List targets
|
||||||
id: generate
|
id: generate
|
||||||
|
|||||||
-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"
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ ___
|
|||||||
* [outputs](#outputs)
|
* [outputs](#outputs)
|
||||||
* [environment variables](#environment-variables)
|
* [environment variables](#environment-variables)
|
||||||
* [Subactions](#subactions)
|
* [Subactions](#subactions)
|
||||||
* [`list-targets`](subaction/list-targets)
|
* [`matrix`](subaction/matrix)
|
||||||
* [Contributing](#contributing)
|
* [Contributing](#contributing)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -157,6 +157,19 @@ additional details about the build execution for all the bake targets,
|
|||||||
including build stats, logs, outputs, and more. The build record can be
|
including build stats, logs, outputs, and more. The build record can be
|
||||||
imported to Docker Desktop for inspecting the build in greater detail.
|
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
|
Summaries are enabled by default, but can be disabled with the
|
||||||
`DOCKER_BUILD_SUMMARY` [environment variable](#environment-variables).
|
`DOCKER_BUILD_SUMMARY` [environment variable](#environment-variables).
|
||||||
|
|
||||||
@@ -187,11 +200,11 @@ 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) |
|
|
||||||
| `allow` | List/CSV | Allow build to access specified resources (e.g., `network.host`) |
|
|
||||||
| `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`) |
|
||||||
@@ -199,6 +212,7 @@ The following inputs can be used as `step.with` keys
|
|||||||
| `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) (e.g., `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
|
||||||
@@ -217,10 +231,11 @@ The following outputs are available
|
|||||||
| `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation is disabled |
|
| `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_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_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`](subaction/list-targets)
|
* [`matrix`](subaction/matrix)
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|||||||
+75
-22
@@ -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([
|
||||||
@@ -145,7 +149,8 @@ describe('getArgs', () => {
|
|||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
1,
|
1,
|
||||||
@@ -160,7 +165,8 @@ describe('getArgs', () => {
|
|||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson
|
'--metadata-file', metadataJson
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
2,
|
2,
|
||||||
@@ -177,7 +183,8 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
'webapp', 'validate'
|
'webapp', 'validate'
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
3,
|
3,
|
||||||
@@ -195,7 +202,8 @@ 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,
|
||||||
@@ -210,8 +218,11 @@ 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/attempts/1`,
|
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
]
|
'--set', `validate-docs.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
|
'--set', `validate-vendor.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
5,
|
5,
|
||||||
@@ -228,7 +239,8 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", `builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`
|
"--provenance", `builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
6,
|
6,
|
||||||
@@ -245,7 +257,8 @@ 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/attempts/1`
|
"--provenance", `mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
7,
|
7,
|
||||||
@@ -262,7 +275,8 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", 'false'
|
"--provenance", 'false'
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
8,
|
8,
|
||||||
@@ -279,7 +293,8 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", 'builder-id=foo'
|
"--provenance", 'builder-id=foo'
|
||||||
]
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
9,
|
9,
|
||||||
@@ -298,9 +313,12 @@ 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/attempts/1`,
|
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
|
'--set', `validate-docs.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
|
'--set', `validate-vendor.attest=type=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,
|
||||||
@@ -318,9 +336,12 @@ 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/attempts/1`,
|
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
|
'--set', `validate-docs.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
|
'--set', `validate-vendor.attest=type=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,
|
||||||
@@ -337,8 +358,11 @@ 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/attempts/1`,
|
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
]
|
'--set', `validate-docs.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
|
'--set', `validate-vendor.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`
|
||||||
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
12,
|
12,
|
||||||
@@ -355,8 +379,11 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--allow', 'network.host',
|
'--allow', 'network.host',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`
|
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
]
|
'--set', `validate-docs.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
|
'--set', `validate-vendor.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`
|
||||||
|
],
|
||||||
|
undefined
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
13,
|
13,
|
||||||
@@ -374,12 +401,38 @@ describe('getArgs', () => {
|
|||||||
'https://github.com/docker/build-push-action.git#refs/heads/master:subdir',
|
'https://github.com/docker/build-push-action.git#refs/heads/master:subdir',
|
||||||
'--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/attempts/1`,
|
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
]
|
'--set', `validate-docs.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
|
'--set', `validate-vendor.attest=type=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);
|
||||||
});
|
});
|
||||||
|
|||||||
+10
-7
@@ -10,22 +10,22 @@ inputs:
|
|||||||
builder:
|
builder:
|
||||||
description: "Builder instance"
|
description: "Builder instance"
|
||||||
required: false
|
required: false
|
||||||
|
workdir:
|
||||||
|
description: "Working directory of bake execution"
|
||||||
|
required: false
|
||||||
|
default: '.'
|
||||||
source:
|
source:
|
||||||
description: "Context to build from. Can be either local or a remote bake definition"
|
description: "Context to build from. Can be either local or a remote bake definition"
|
||||||
required: false
|
required: false
|
||||||
allow:
|
allow:
|
||||||
description: "Allow build to access specified resources (e.g., network.host)"
|
description: "Allow build to access specified resources (e.g., network.host)"
|
||||||
required: false
|
required: false
|
||||||
|
call:
|
||||||
|
description: "Set method for evaluating build (e.g., check)"
|
||||||
|
required: false
|
||||||
files:
|
files:
|
||||||
description: "List of bake definition files"
|
description: "List of bake definition files"
|
||||||
required: false
|
required: false
|
||||||
workdir:
|
|
||||||
description: "Working directory of bake execution"
|
|
||||||
required: false
|
|
||||||
default: '.'
|
|
||||||
targets:
|
|
||||||
description: "List of bake targets"
|
|
||||||
required: false
|
|
||||||
no-cache:
|
no-cache:
|
||||||
description: "Do not use cache when building the image"
|
description: "Do not use cache when building the image"
|
||||||
required: false
|
required: false
|
||||||
@@ -51,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 }}
|
||||||
|
|||||||
+302
@@ -0,0 +1,302 @@
|
|||||||
|
"use strict";
|
||||||
|
exports.id = 606;
|
||||||
|
exports.ids = [606];
|
||||||
|
exports.modules = {
|
||||||
|
|
||||||
|
/***/ 606:
|
||||||
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||||
|
|
||||||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ "default": () => (/* binding */ pMap)
|
||||||
|
/* harmony export */ });
|
||||||
|
/* unused harmony exports pMapIterable, pMapSkip */
|
||||||
|
async function pMap(
|
||||||
|
iterable,
|
||||||
|
mapper,
|
||||||
|
{
|
||||||
|
concurrency = Number.POSITIVE_INFINITY,
|
||||||
|
stopOnError = true,
|
||||||
|
signal,
|
||||||
|
} = {},
|
||||||
|
) {
|
||||||
|
return new Promise((resolve_, reject_) => {
|
||||||
|
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
|
||||||
|
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof mapper !== 'function') {
|
||||||
|
throw new TypeError('Mapper function is required');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
|
||||||
|
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = [];
|
||||||
|
const errors = [];
|
||||||
|
const skippedIndexesMap = new Map();
|
||||||
|
let isRejected = false;
|
||||||
|
let isResolved = false;
|
||||||
|
let isIterableDone = false;
|
||||||
|
let resolvingCount = 0;
|
||||||
|
let currentIndex = 0;
|
||||||
|
const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
|
||||||
|
|
||||||
|
const signalListener = () => {
|
||||||
|
reject(signal.reason);
|
||||||
|
};
|
||||||
|
|
||||||
|
const cleanup = () => {
|
||||||
|
signal?.removeEventListener('abort', signalListener);
|
||||||
|
};
|
||||||
|
|
||||||
|
const resolve = value => {
|
||||||
|
resolve_(value);
|
||||||
|
cleanup();
|
||||||
|
};
|
||||||
|
|
||||||
|
const reject = reason => {
|
||||||
|
isRejected = true;
|
||||||
|
isResolved = true;
|
||||||
|
reject_(reason);
|
||||||
|
cleanup();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (signal) {
|
||||||
|
if (signal.aborted) {
|
||||||
|
reject(signal.reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
signal.addEventListener('abort', signalListener, {once: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
const next = async () => {
|
||||||
|
if (isResolved) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextItem = await iterator.next();
|
||||||
|
|
||||||
|
const index = currentIndex;
|
||||||
|
currentIndex++;
|
||||||
|
|
||||||
|
// Note: `iterator.next()` can be called many times in parallel.
|
||||||
|
// This can cause multiple calls to this `next()` function to
|
||||||
|
// receive a `nextItem` with `done === true`.
|
||||||
|
// The shutdown logic that rejects/resolves must be protected
|
||||||
|
// so it runs only one time as the `skippedIndex` logic is
|
||||||
|
// non-idempotent.
|
||||||
|
if (nextItem.done) {
|
||||||
|
isIterableDone = true;
|
||||||
|
|
||||||
|
if (resolvingCount === 0 && !isResolved) {
|
||||||
|
if (!stopOnError && errors.length > 0) {
|
||||||
|
reject(new AggregateError(errors)); // eslint-disable-line unicorn/error-message
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isResolved = true;
|
||||||
|
|
||||||
|
if (skippedIndexesMap.size === 0) {
|
||||||
|
resolve(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pureResult = [];
|
||||||
|
|
||||||
|
// Support multiple `pMapSkip`'s.
|
||||||
|
for (const [index, value] of result.entries()) {
|
||||||
|
if (skippedIndexesMap.get(index) === pMapSkip) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pureResult.push(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(pureResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolvingCount++;
|
||||||
|
|
||||||
|
// Intentionally detached
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const element = await nextItem.value;
|
||||||
|
|
||||||
|
if (isResolved) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = await mapper(element, index);
|
||||||
|
|
||||||
|
// Use Map to stage the index of the element.
|
||||||
|
if (value === pMapSkip) {
|
||||||
|
skippedIndexesMap.set(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
result[index] = value;
|
||||||
|
|
||||||
|
resolvingCount--;
|
||||||
|
await next();
|
||||||
|
} catch (error) {
|
||||||
|
if (stopOnError) {
|
||||||
|
reject(error);
|
||||||
|
} else {
|
||||||
|
errors.push(error);
|
||||||
|
resolvingCount--;
|
||||||
|
|
||||||
|
// In that case we can't really continue regardless of `stopOnError` state
|
||||||
|
// since an iterable is likely to continue throwing after it throws once.
|
||||||
|
// If we continue calling `next()` indefinitely we will likely end up
|
||||||
|
// in an infinite loop of failed iteration.
|
||||||
|
try {
|
||||||
|
await next();
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create the concurrent runners in a detached (non-awaited)
|
||||||
|
// promise. We need this so we can await the `next()` calls
|
||||||
|
// to stop creating runners before hitting the concurrency limit
|
||||||
|
// if the iterable has already been marked as done.
|
||||||
|
// NOTE: We *must* do this for async iterators otherwise we'll spin up
|
||||||
|
// infinite `next()` calls by default and never start the event loop.
|
||||||
|
(async () => {
|
||||||
|
for (let index = 0; index < concurrency; index++) {
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await next();
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isIterableDone || isRejected) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function pMapIterable(
|
||||||
|
iterable,
|
||||||
|
mapper,
|
||||||
|
{
|
||||||
|
concurrency = Number.POSITIVE_INFINITY,
|
||||||
|
backpressure = concurrency,
|
||||||
|
} = {},
|
||||||
|
) {
|
||||||
|
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
|
||||||
|
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof mapper !== 'function') {
|
||||||
|
throw new TypeError('Mapper function is required');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
|
||||||
|
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!((Number.isSafeInteger(backpressure) && backpressure >= concurrency) || backpressure === Number.POSITIVE_INFINITY)) {
|
||||||
|
throw new TypeError(`Expected \`backpressure\` to be an integer from \`concurrency\` (${concurrency}) and up or \`Infinity\`, got \`${backpressure}\` (${typeof backpressure})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
async * [Symbol.asyncIterator]() {
|
||||||
|
const iterator = iterable[Symbol.asyncIterator] === undefined ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
|
||||||
|
|
||||||
|
const promises = [];
|
||||||
|
let pendingPromisesCount = 0;
|
||||||
|
let isDone = false;
|
||||||
|
let index = 0;
|
||||||
|
|
||||||
|
function trySpawn() {
|
||||||
|
if (isDone || !(pendingPromisesCount < concurrency && promises.length < backpressure)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pendingPromisesCount++;
|
||||||
|
|
||||||
|
const promise = (async () => {
|
||||||
|
const {done, value} = await iterator.next();
|
||||||
|
|
||||||
|
if (done) {
|
||||||
|
pendingPromisesCount--;
|
||||||
|
return {done: true};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn if still below concurrency and backpressure limit
|
||||||
|
trySpawn();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const returnValue = await mapper(await value, index++);
|
||||||
|
|
||||||
|
pendingPromisesCount--;
|
||||||
|
|
||||||
|
if (returnValue === pMapSkip) {
|
||||||
|
const index = promises.indexOf(promise);
|
||||||
|
|
||||||
|
if (index > 0) {
|
||||||
|
promises.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn if still below backpressure limit and just dropped below concurrency limit
|
||||||
|
trySpawn();
|
||||||
|
|
||||||
|
return {done: false, value: returnValue};
|
||||||
|
} catch (error) {
|
||||||
|
pendingPromisesCount--;
|
||||||
|
isDone = true;
|
||||||
|
return {error};
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
promises.push(promise);
|
||||||
|
}
|
||||||
|
|
||||||
|
trySpawn();
|
||||||
|
|
||||||
|
while (promises.length > 0) {
|
||||||
|
const {error, done, value} = await promises[0]; // eslint-disable-line no-await-in-loop
|
||||||
|
|
||||||
|
promises.shift();
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (done) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn if just dropped below backpressure limit and below the concurrency limit
|
||||||
|
trySpawn();
|
||||||
|
|
||||||
|
if (value === pMapSkip) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const pMapSkip = Symbol('skip');
|
||||||
|
|
||||||
|
|
||||||
|
/***/ })
|
||||||
|
|
||||||
|
};
|
||||||
|
;
|
||||||
|
//# sourceMappingURL=606.index.js.map
|
||||||
+1
File diff suppressed because one or more lines are too long
+51
-19
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-3920
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
+13
-13
@@ -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.11.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@docker/actions-toolkit": "^0.55.0",
|
"@docker/actions-toolkit": "^0.68.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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-39
@@ -11,11 +11,12 @@ 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';
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
allow: string[];
|
|
||||||
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;
|
||||||
@@ -23,17 +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 {
|
||||||
allow: Util.getInputList('allow'),
|
|
||||||
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'),
|
||||||
@@ -41,33 +43,11 @@ 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')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sanitizeInputs(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 === false) {
|
|
||||||
continue;
|
|
||||||
} else if (Array.isArray(value) && value.length === 0) {
|
|
||||||
continue;
|
|
||||||
} else if (!value) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (key === 'workdir' && value === '.') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
res[key] = value;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getArgs(inputs: Inputs, definition: BakeDefinition, toolkit: Toolkit): Promise<Array<string>> {
|
export async function getArgs(inputs: Inputs, definition: BakeDefinition, toolkit: Toolkit): Promise<Array<string>> {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
return [
|
return [
|
||||||
@@ -91,6 +71,12 @@ async function getBakeArgs(inputs: Inputs, definition: BakeDefinition, toolkit:
|
|||||||
args.push('--allow', 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);
|
||||||
});
|
});
|
||||||
@@ -103,17 +89,23 @@ 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
|
// check if provenance attestation is already specified in the bake
|
||||||
|
// definition and if 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.
|
||||||
if (GitHub.context.payload.repository?.private ?? false) {
|
for (const targetName in definition.target) {
|
||||||
// if this is a private repository, we set the default provenance
|
const target = definition.target[targetName];
|
||||||
// attributes being set in buildx: https://github.com/docker/buildx/blob/fb27e3f919dcbf614d7126b10c2bc2d0b1927eb6/build/build.go#L603
|
if (!Array.isArray(target.attest) || !target.attest.some(attest => attest?.type === 'provenance')) {
|
||||||
args.push('--provenance', Build.resolveProvenanceAttrs(`mode=min,inline-only=true`));
|
if (GitHub.context.payload.repository?.private ?? false) {
|
||||||
} else {
|
// if this is a private repository, we set the default provenance
|
||||||
// for a public repository, we set max provenance mode.
|
// attributes being set in buildx: https://github.com/docker/buildx/blob/fb27e3f919dcbf614d7126b10c2bc2d0b1927eb6/build/build.go#L603
|
||||||
args.push('--provenance', Build.resolveProvenanceAttrs(`mode=max`));
|
args.push('--set', `${targetName}.attest=type=provenance,${Build.resolveProvenanceAttrs(`mode=min,inline-only=true`)}`);
|
||||||
|
} else {
|
||||||
|
// for a public repository, we set max provenance mode.
|
||||||
|
args.push('--set', `${targetName}.attest=type=provenance,${Build.resolveProvenanceAttrs(`mode=max`)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inputs.sbom) {
|
if (inputs.sbom) {
|
||||||
@@ -155,3 +147,10 @@ function getSourceInput(name: string): string {
|
|||||||
}
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
|
|||||||
+38
-8
@@ -26,8 +26,8 @@ actionsToolkit.run(
|
|||||||
const startedTime = new Date();
|
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)}`);
|
core.debug(`inputs: ${JSON.stringify(inputs)}`);
|
||||||
stateHelper.setInputs(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'];
|
||||||
@@ -88,6 +88,8 @@ actionsToolkit.run(
|
|||||||
let builder: BuilderInfo;
|
let builder: BuilderInfo;
|
||||||
await core.group(`Builder info`, async () => {
|
await core.group(`Builder info`, async () => {
|
||||||
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));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -144,8 +146,26 @@ actionsToolkit.run(
|
|||||||
env: buildEnv,
|
env: buildEnv,
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.exitCode != 0) {
|
||||||
err = 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'}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -189,12 +209,12 @@ actionsToolkit.run(
|
|||||||
await core.group(`Check build summary support`, async () => {
|
await core.group(`Check build summary support`, async () => {
|
||||||
if (!buildSummaryEnabled()) {
|
if (!buildSummaryEnabled()) {
|
||||||
core.info('Build summary disabled');
|
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) {
|
} else if (GitHub.isGHES) {
|
||||||
core.info('Build summary is not yet supported on GHES');
|
core.info('Build summary is not yet supported on GHES');
|
||||||
} else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) {
|
} else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) {
|
||||||
core.info('Build summary requires Buildx >= 0.13.0');
|
core.info('Build summary requires Buildx >= 0.13.0');
|
||||||
} else if (builder && builder.driver === 'cloud') {
|
|
||||||
core.info('Build summary is not yet supported with Docker Build Cloud');
|
|
||||||
} else if (refs.length == 0) {
|
} else if (refs.length == 0) {
|
||||||
core.info('Build summary requires at least one build reference');
|
core.info('Build summary requires at least one build reference');
|
||||||
} else {
|
} else {
|
||||||
@@ -220,7 +240,8 @@ actionsToolkit.run(
|
|||||||
|
|
||||||
const buildxHistory = new BuildxHistory();
|
const buildxHistory = new BuildxHistory();
|
||||||
const exportRes = await buildxHistory.export({
|
const exportRes = await buildxHistory.export({
|
||||||
refs: stateHelper.buildRefs
|
refs: stateHelper.buildRefs,
|
||||||
|
useContainer: buildExportLegacy()
|
||||||
});
|
});
|
||||||
core.info(`Build records written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
|
core.info(`Build records written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
|
||||||
|
|
||||||
@@ -236,8 +257,10 @@ actionsToolkit.run(
|
|||||||
await GitHub.writeBuildSummary({
|
await GitHub.writeBuildSummary({
|
||||||
exportRes: exportRes,
|
exportRes: exportRes,
|
||||||
uploadRes: uploadRes,
|
uploadRes: uploadRes,
|
||||||
inputs: stateHelper.inputs,
|
inputs: stateHelper.summaryInputs,
|
||||||
bakeDefinition: stateHelper.bakeDefinition
|
bakeDefinition: stateHelper.bakeDefinition,
|
||||||
|
driver: stateHelper.builderDriver,
|
||||||
|
endpoint: stateHelper.builderEndpoint
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
core.warning(e.message);
|
core.warning(e.message);
|
||||||
@@ -317,3 +340,10 @@ function buildRecordRetentionDays(): number | undefined {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildExportLegacy(): boolean {
|
||||||
|
if (process.env.DOCKER_BUILD_EXPORT_LEGACY) {
|
||||||
|
return Util.parseBool(process.env.DOCKER_BUILD_EXPORT_LEGACY);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
+31
-4
@@ -2,11 +2,15 @@ import * as core from '@actions/core';
|
|||||||
|
|
||||||
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
||||||
|
|
||||||
import {Inputs, sanitizeInputs} from './context';
|
import {Inputs} from './context';
|
||||||
|
|
||||||
export const tmpDir = process.env['STATE_tmpDir'] || '';
|
export const tmpDir = process.env['STATE_tmpDir'] || '';
|
||||||
export const inputs = process.env['STATE_inputs'] ? JSON.parse(process.env['STATE_inputs']) : undefined;
|
|
||||||
|
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 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 buildRefs = process.env['STATE_buildRefs'] ? process.env['STATE_buildRefs'].split(',') : [];
|
||||||
export const isSummarySupported = !!process.env['STATE_isSummarySupported'];
|
export const isSummarySupported = !!process.env['STATE_isSummarySupported'];
|
||||||
|
|
||||||
@@ -14,8 +18,12 @@ export function setTmpDir(tmpDir: string) {
|
|||||||
core.saveState('tmpDir', tmpDir);
|
core.saveState('tmpDir', tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setInputs(inputs: Inputs) {
|
export function setBuilderDriver(builderDriver: string) {
|
||||||
core.saveState('inputs', JSON.stringify(sanitizeInputs(inputs)));
|
core.saveState('builderDriver', builderDriver);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setBuilderEndpoint(builderEndpoint: string) {
|
||||||
|
core.saveState('builderEndpoint', builderEndpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setBakeDefinition(bakeDefinition: BakeDefinition) {
|
export function setBakeDefinition(bakeDefinition: BakeDefinition) {
|
||||||
@@ -29,3 +37,22 @@ export function setBuildRefs(buildRefs: Array<string>) {
|
|||||||
export function setSummarySupported() {
|
export function setSummarySupported() {
|
||||||
core.saveState('isSummarySupported', 'true');
|
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));
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
|
> [!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
|
## 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),
|
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.
|
so you can distribute your builds across multiple runners.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -55,9 +60,6 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
target: ${{ fromJson(needs.prepare.outputs.targets) }}
|
target: ${{ fromJson(needs.prepare.outputs.targets) }}
|
||||||
steps:
|
steps:
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
-
|
-
|
||||||
name: Validate
|
name: Validate
|
||||||
uses: docker/bake-action@v6
|
uses: docker/bake-action@v6
|
||||||
@@ -79,6 +81,6 @@ jobs:
|
|||||||
|
|
||||||
The following outputs are available
|
The following outputs are available
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
|------------|----------|----------------------------|
|
|------------|----------|---------------------------|
|
||||||
| `targets` | List/CSV | List of extracted targest |
|
| `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(/[\r?\n,]+/).filter(Boolean) : [];
|
|
||||||
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));
|
||||||
|
});
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
FROM busybox AS t1
|
||||||
|
RUN echo "Hello t1"
|
||||||
|
|
||||||
|
FROM busybox AS t2
|
||||||
|
RUN echo "Hello t2"
|
||||||
|
|
||||||
|
FROM busybox AS t3
|
||||||
|
RUN echo "Hello t3"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
group "default" {
|
||||||
|
targets = ["t1", "t2", "t3"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "t1" {
|
||||||
|
target = "t1"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "t2" {
|
||||||
|
target = "t2"
|
||||||
|
attest = ["type=provenance,mode=min"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "t3" {
|
||||||
|
target = "t3"
|
||||||
|
attest = ["type=sbom"]
|
||||||
|
}
|
||||||
@@ -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"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user