mirror of
https://github.com/docker/bake-action.git
synced 2026-06-05 17:48:40 +02:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a9a8d4944 | |||
| 646f0499ff | |||
| 94bc82a583 | |||
| b6c9154dfe | |||
| a50446b491 | |||
| 419be9c19b |
@@ -0,0 +1,3 @@
|
|||||||
|
/dist/**
|
||||||
|
/coverage/**
|
||||||
|
/node_modules/**
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
"es6": true,
|
||||||
|
"jest": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:jest/recommended",
|
||||||
|
"plugin:prettier/recommended"
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint",
|
||||||
|
"jest",
|
||||||
|
"prettier"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -4,12 +4,6 @@ updates:
|
|||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
cooldown:
|
|
||||||
default-days: 2
|
|
||||||
groups:
|
|
||||||
crazy-max-dot-github:
|
|
||||||
patterns:
|
|
||||||
- "crazy-max/.github/*"
|
|
||||||
labels:
|
labels:
|
||||||
- "dependencies"
|
- "dependencies"
|
||||||
- "bot"
|
- "bot"
|
||||||
@@ -17,10 +11,6 @@ updates:
|
|||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
cooldown:
|
|
||||||
default-days: 2
|
|
||||||
exclude:
|
|
||||||
- "@docker/actions-toolkit"
|
|
||||||
versioning-strategy: "increase"
|
versioning-strategy: "increase"
|
||||||
allow:
|
allow:
|
||||||
- dependency-type: "production"
|
- dependency-type: "production"
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
@@ -1,8 +1,5 @@
|
|||||||
name: ci-subaction
|
name: ci-subaction
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -28,62 +25,75 @@ on:
|
|||||||
- 'test/**'
|
- 'test/**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
matrix:
|
list-targets-group:
|
||||||
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Matrix gen
|
name: Matrix gen
|
||||||
id: gen
|
id: gen
|
||||||
uses: ./subaction/matrix
|
uses: ./subaction/list-targets
|
||||||
with:
|
with:
|
||||||
workdir: ./test/${{ matrix.testdir }}
|
workdir: ./test/group
|
||||||
target: ${{ matrix.target }}
|
|
||||||
fields: ${{ matrix.fields }}
|
|
||||||
-
|
-
|
||||||
name: Check output
|
name: Check targets
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@v7
|
||||||
env:
|
|
||||||
INPUT_MATRIX: ${{ steps.gen.outputs.matrix }}
|
|
||||||
INPUT_EXPECTED: ${{ matrix.expected }}
|
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const matrix = JSON.stringify(JSON.parse(core.getInput('matrix')));
|
const targets = `${{ steps.gen.outputs.targets }}`;
|
||||||
const expected = JSON.stringify(JSON.parse(core.getInput('expected')));
|
if (!targets) {
|
||||||
if (matrix !== expected) {
|
core.setFailed('No targets generated');
|
||||||
throw new Error(`Matrix do not match expected values: ${matrix} != ${expected}`);
|
|
||||||
} else {
|
|
||||||
core.info(`✅`);
|
|
||||||
}
|
}
|
||||||
|
core.info(`targets=${targets}`);
|
||||||
|
|
||||||
|
list-targets-group-matrix:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Matrix gen
|
||||||
|
id: gen
|
||||||
|
uses: ./subaction/list-targets
|
||||||
|
with:
|
||||||
|
workdir: ./test/group-matrix
|
||||||
|
target: validate
|
||||||
|
-
|
||||||
|
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}`);
|
||||||
|
|
||||||
|
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}`);
|
||||||
|
|||||||
+90
-270
@@ -1,8 +1,5 @@
|
|||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -35,8 +32,8 @@ on:
|
|||||||
- 'subaction/**'
|
- 'subaction/**'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
BUILDX_VERSION: edge
|
BUILDX_VERSION: latest
|
||||||
BUILDKIT_IMAGE: moby/buildkit:latest
|
BUILDKIT_IMAGE: moby/buildkit:buildx-stable-1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
bake:
|
bake:
|
||||||
@@ -49,20 +46,20 @@ jobs:
|
|||||||
- release
|
- release
|
||||||
services:
|
services:
|
||||||
registry:
|
registry:
|
||||||
image: registry:2.8.3@sha256:a3d8aaa63ed8681a604f1dea0aa03f100d5895b6a58ace528858a7b332415373
|
image: registry:2
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
|
uses: docker/setup-qemu-action@v3
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -72,7 +69,6 @@ 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
|
||||||
@@ -85,13 +81,12 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
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: |
|
||||||
@@ -102,7 +97,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Stop docker
|
name: Stop docker
|
||||||
run: |
|
run: |
|
||||||
@@ -113,33 +108,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: |
|
||||||
if [ "${{ steps.bake.outcome }}" != "failure" ] || [ "${{ steps.bake.conclusion }}" != "success" ]; then
|
echo "${{ toJson(steps.bake) }}"
|
||||||
echo "::error::Should have failed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
error-source:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
-
|
|
||||||
name: Build
|
|
||||||
id: bake
|
|
||||||
continue-on-error: true
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
source: ./does-not-exist
|
|
||||||
-
|
|
||||||
name: Check
|
|
||||||
run: |
|
|
||||||
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
|
||||||
@@ -150,7 +124,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Uninstall docker cli
|
name: Uninstall docker cli
|
||||||
run: |
|
run: |
|
||||||
@@ -161,7 +135,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -170,16 +144,15 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: .
|
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
|
|
||||||
remote:
|
source:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -201,10 +174,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -214,7 +187,7 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: ./test/go
|
workdir: ./test/go
|
||||||
targets: binary
|
targets: binary
|
||||||
provenance: ${{ matrix.attrs }}
|
provenance: ${{ matrix.attrs }}
|
||||||
set: |
|
set: |
|
||||||
@@ -236,16 +209,16 @@ jobs:
|
|||||||
output: /tmp/bake-build
|
output: /tmp/bake-build
|
||||||
services:
|
services:
|
||||||
registry:
|
registry:
|
||||||
image: registry:2.8.3@sha256:a3d8aaa63ed8681a604f1dea0aa03f100d5895b6a58ace528858a7b332415373
|
image: registry:2
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -255,7 +228,7 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: ./test/go
|
workdir: ./test/go
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
sbom: true
|
sbom: true
|
||||||
set: |
|
set: |
|
||||||
@@ -290,18 +263,18 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
registry:
|
registry:
|
||||||
image: registry:2.8.3@sha256:a3d8aaa63ed8681a604f1dea0aa03f100d5895b6a58ace528858a7b332415373
|
image: registry:2
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: ./test/go
|
workdir: ./test/go
|
||||||
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
|
||||||
@@ -311,16 +284,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
registry:
|
registry:
|
||||||
image: registry:2.8.3@sha256:a3d8aaa63ed8681a604f1dea0aa03f100d5895b6a58ace528858a7b332415373
|
image: registry:2
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -330,7 +303,7 @@ jobs:
|
|||||||
name: Build and push
|
name: Build and push
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: ./test/group
|
workdir: ./test/group
|
||||||
push: true
|
push: true
|
||||||
set: |
|
set: |
|
||||||
t1.tags=localhost:5000/name/app:t1
|
t1.tags=localhost:5000/name/app:t1
|
||||||
@@ -341,7 +314,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set malformed docker config
|
name: Set malformed docker config
|
||||||
run: |
|
run: |
|
||||||
@@ -351,7 +324,6 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: .
|
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
|
|
||||||
@@ -359,7 +331,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
squid-proxy:
|
squid-proxy:
|
||||||
image: ubuntu/squid:latest@sha256:6a097f68bae708cedbabd6188d68c7e2e7a38cedd05a176e1cc0ba29e3bbe029
|
image: ubuntu/squid:latest
|
||||||
ports:
|
ports:
|
||||||
- 3128:3128
|
- 3128:3128
|
||||||
steps:
|
steps:
|
||||||
@@ -370,7 +342,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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set proxy config
|
name: Set proxy config
|
||||||
run: |
|
run: |
|
||||||
@@ -378,7 +350,7 @@ jobs:
|
|||||||
echo '{"proxies":{"default":{"httpProxy":"http://127.0.0.1:3128","httpsProxy":"http://127.0.0.1:3128"}}}' > ~/.docker/config.json
|
echo '{"proxies":{"default":{"httpProxy":"http://127.0.0.1:3128","httpsProxy":"http://127.0.0.1:3128"}}}' > ~/.docker/config.json
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -389,7 +361,6 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: .
|
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
targets: app-proxy
|
targets: app-proxy
|
||||||
@@ -398,7 +369,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
squid-proxy:
|
squid-proxy:
|
||||||
image: ubuntu/squid:latest@sha256:6a097f68bae708cedbabd6188d68c7e2e7a38cedd05a176e1cc0ba29e3bbe029
|
image: ubuntu/squid:latest
|
||||||
ports:
|
ports:
|
||||||
- 3128:3128
|
- 3128:3128
|
||||||
steps:
|
steps:
|
||||||
@@ -409,10 +380,10 @@ 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -425,7 +396,6 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: .
|
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
|
|
||||||
@@ -434,10 +404,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -446,40 +416,17 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
files: |
|
source: "{{defaultContext}}"
|
||||||
./test/config.hcl
|
|
||||||
|
|
||||||
git-context-query:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
||||||
with:
|
|
||||||
version: v0.33.0
|
|
||||||
driver-opts: |
|
|
||||||
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
|
||||||
-
|
|
||||||
name: Build
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
files: |
|
|
||||||
./test/config.hcl
|
|
||||||
env:
|
|
||||||
BUILDX_SEND_GIT_QUERY_AS_INPUT: true
|
|
||||||
|
|
||||||
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -487,29 +434,29 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
|
uses: docker/metadata-action@v5
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
source: "{{defaultContext}}"
|
||||||
files: |
|
files: |
|
||||||
./test/config.hcl
|
|
||||||
cwd://${{ steps.meta.outputs.bake-file }}
|
cwd://${{ steps.meta.outputs.bake-file }}
|
||||||
|
|
||||||
multi-output:
|
multi-output:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
registry:
|
registry:
|
||||||
image: registry:2.8.3@sha256:a3d8aaa63ed8681a604f1dea0aa03f100d5895b6a58ace528858a7b332415373
|
image: registry:2
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -518,7 +465,7 @@ jobs:
|
|||||||
name: Build and push
|
name: Build and push
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: ./test/go
|
workdir: ./test/go
|
||||||
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
|
||||||
@@ -543,16 +490,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
registry:
|
registry:
|
||||||
image: registry:2.8.3@sha256:a3d8aaa63ed8681a604f1dea0aa03f100d5895b6a58ace528858a7b332415373
|
image: registry:2
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -561,7 +508,7 @@ jobs:
|
|||||||
name: Build and push
|
name: Build and push
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: ./test/go
|
workdir: ./test/go
|
||||||
targets: image
|
targets: image
|
||||||
load: true
|
load: true
|
||||||
push: true
|
push: true
|
||||||
@@ -581,10 +528,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -599,15 +546,38 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DOCKER_BUILD_SUMMARY: false
|
DOCKER_BUILD_SUMMARY: false
|
||||||
|
|
||||||
|
summary-disable-deprecated:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
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_NO_SUMMARY: true
|
||||||
|
|
||||||
summary-not-supported:
|
summary-not-supported:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: v0.12.1
|
version: v0.12.1
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -625,10 +595,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -654,10 +624,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -678,15 +648,15 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
buildx-version:
|
buildx-version:
|
||||||
- edge
|
- latest
|
||||||
- v0.14.1
|
- v0.14.1
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.buildx-version }}
|
version: ${{ matrix.buildx-version }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -695,7 +665,7 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: ./test
|
workdir: ./test
|
||||||
files: |
|
files: |
|
||||||
./lint.hcl
|
./lint.hcl
|
||||||
|
|
||||||
@@ -704,10 +674,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -716,7 +686,7 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source: ./test
|
workdir: ./test
|
||||||
files: |
|
files: |
|
||||||
./lint.hcl
|
./lint.hcl
|
||||||
env:
|
env:
|
||||||
@@ -728,17 +698,16 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
buildx-version:
|
buildx-version:
|
||||||
- edge
|
- v0.19.0-rc2
|
||||||
- v0.19.0
|
|
||||||
- v0.18.0
|
- v0.18.0
|
||||||
- v0.17.1
|
- v0.17.1
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.buildx-version }}
|
version: ${{ matrix.buildx-version }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
@@ -751,152 +720,3 @@ 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
-
|
|
||||||
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
||||||
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: ./test
|
|
||||||
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
||||||
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: ./test
|
|
||||||
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
||||||
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
||||||
with:
|
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
|
||||||
driver-opts: |
|
|
||||||
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
source: ./test/attest
|
|
||||||
|
|
||||||
var:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
||||||
with:
|
|
||||||
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
|
||||||
driver-opts: |
|
|
||||||
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
|
||||||
-
|
|
||||||
name: Build
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
source: ./test/go
|
|
||||||
targets: binary
|
|
||||||
vars: |
|
|
||||||
DESTDIR=/tmp/build
|
|
||||||
-
|
|
||||||
name: Check output folder
|
|
||||||
working-directory: /tmp/build
|
|
||||||
run: |
|
|
||||||
tree .
|
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
name: codeql
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
- 'releases/v*'
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
env:
|
|
||||||
NODE_VERSION: "24"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
analyze:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
-
|
|
||||||
name: Enable corepack
|
|
||||||
run: |
|
|
||||||
corepack enable
|
|
||||||
yarn --version
|
|
||||||
-
|
|
||||||
name: Set up Node
|
|
||||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
||||||
with:
|
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
|
||||||
-
|
|
||||||
name: Initialize CodeQL
|
|
||||||
uses: github/codeql-action/init@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5
|
|
||||||
with:
|
|
||||||
languages: javascript-typescript
|
|
||||||
build-mode: none
|
|
||||||
-
|
|
||||||
name: Perform CodeQL Analysis
|
|
||||||
uses: github/codeql-action/analyze@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5
|
|
||||||
with:
|
|
||||||
category: "/language:javascript-typescript"
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
name: pr-assign-author
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request_target: # zizmor: ignore[dangerous-triggers] safe to use without checkout
|
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- reopened
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
run:
|
|
||||||
uses: crazy-max/.github/.github/workflows/pr-assign-author.yml@9ba6e6f9450baf3b1237f8035c1fdc45932510bd # v1.8.0
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pull-requests: write
|
|
||||||
@@ -1,12 +1,5 @@
|
|||||||
name: publish
|
name: publish
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types:
|
types:
|
||||||
@@ -22,7 +15,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Publish
|
name: Publish
|
||||||
uses: actions/publish-immutable-action@4bc8754ffc40f27910afb20287dbbbb675a4e978 # v0.0.4
|
uses: actions/publish-immutable-action@v0.0.4
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
name: test
|
name: test
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -26,16 +23,15 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0
|
uses: docker/bake-action@v5
|
||||||
with:
|
with:
|
||||||
source: .
|
|
||||||
targets: test
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
|
uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
files: ./coverage/clover.xml
|
files: ./coverage/clover.xml
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
name: update-dist
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- synchronize
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update-dist:
|
|
||||||
if: github.actor == 'dependabot[bot]' && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == github.event.pull_request.head.repo.full_name
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: GitHub auth token from GitHub App
|
|
||||||
id: docker-read-app
|
|
||||||
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
|
||||||
with:
|
|
||||||
app-id: ${{ secrets.GHACTIONS_REPO_WRITE_APP_ID }}
|
|
||||||
private-key: ${{ secrets.GHACTIONS_REPO_WRITE_APP_PRIVATE_KEY }}
|
|
||||||
owner: docker
|
|
||||||
repositories: bake-action
|
|
||||||
permission-contents: write
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
with:
|
|
||||||
ref: ${{ github.event.pull_request.head.ref }}
|
|
||||||
fetch-depth: 0
|
|
||||||
token: ${{ steps.docker-read-app.outputs.token }}
|
|
||||||
-
|
|
||||||
name: Build
|
|
||||||
uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0
|
|
||||||
with:
|
|
||||||
source: .
|
|
||||||
targets: build
|
|
||||||
-
|
|
||||||
name: Commit and push dist
|
|
||||||
run: |
|
|
||||||
if [ -n "$(git status --porcelain -- dist)" ]; then
|
|
||||||
(
|
|
||||||
set -x
|
|
||||||
git config user.name "github-actions[bot]"
|
|
||||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
||||||
git add dist
|
|
||||||
git commit -m "chore: update generated content"
|
|
||||||
git push
|
|
||||||
)
|
|
||||||
else
|
|
||||||
echo "No changes in dist"
|
|
||||||
fi
|
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
name: validate
|
name: validate
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -18,15 +15,15 @@ jobs:
|
|||||||
prepare:
|
prepare:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.generate.outputs.matrix }}
|
targets: ${{ steps.generate.outputs.targets }}
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: List targets
|
name: List targets
|
||||||
id: generate
|
id: generate
|
||||||
uses: ./subaction/matrix
|
uses: ./subaction/list-targets
|
||||||
with:
|
with:
|
||||||
target: validate
|
target: validate
|
||||||
|
|
||||||
@@ -37,10 +34,13 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include: ${{ fromJson(needs.prepare.outputs.matrix) }}
|
target: ${{ fromJson(needs.prepare.outputs.targets) }}
|
||||||
steps:
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Validate
|
name: Validate
|
||||||
uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0
|
uses: docker/bake-action@v5
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
name: zizmor
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
- 'releases/v*'
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
zizmor:
|
|
||||||
uses: crazy-max/.github/.github/workflows/zizmor.yml@9ba6e6f9450baf3b1237f8035c1fdc45932510bd # v1.8.0
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
with:
|
|
||||||
min-severity: medium
|
|
||||||
min-confidence: medium
|
|
||||||
persona: pedantic
|
|
||||||
+2
-1
@@ -6,5 +6,6 @@
|
|||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"trailingComma": "none",
|
"trailingComma": "none",
|
||||||
"bracketSpacing": false,
|
"bracketSpacing": false,
|
||||||
"arrowParens": "avoid"
|
"arrowParens": "avoid",
|
||||||
|
"parser": "typescript"
|
||||||
}
|
}
|
||||||
|
|||||||
+541
File diff suppressed because one or more lines are too long
+4
-8
@@ -1,9 +1,3 @@
|
|||||||
# https://yarnpkg.com/configuration/yarnrc
|
|
||||||
|
|
||||||
compressionLevel: mixed
|
|
||||||
enableGlobalCache: false
|
|
||||||
enableHardenedMode: true
|
|
||||||
|
|
||||||
logFilters:
|
logFilters:
|
||||||
- code: YN0013
|
- code: YN0013
|
||||||
level: discard
|
level: discard
|
||||||
@@ -11,7 +5,9 @@ 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,66 +14,97 @@ as a high-level build command.
|
|||||||
___
|
___
|
||||||
|
|
||||||
* [Usage](#usage)
|
* [Usage](#usage)
|
||||||
* [Git context](#git-context)
|
|
||||||
* [Path context](#path-context)
|
* [Path context](#path-context)
|
||||||
|
* [Git context](#git-context)
|
||||||
* [Summaries](#summaries)
|
* [Summaries](#summaries)
|
||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [outputs](#outputs)
|
* [outputs](#outputs)
|
||||||
* [environment variables](#environment-variables)
|
* [environment variables](#environment-variables)
|
||||||
* [Subactions](#subactions)
|
* [Subactions](#subactions)
|
||||||
* [`matrix`](subaction/matrix)
|
* [`list-targets`](subaction/list-targets)
|
||||||
* [Notes](#notes)
|
|
||||||
* [Source semantics](#source-semantics)
|
|
||||||
* [Contributing](#contributing)
|
* [Contributing](#contributing)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Git context
|
### Path context
|
||||||
|
|
||||||
Since `v6` this action uses the [Git context](https://docs.docker.com/build/bake/remote-definition/)
|
By default, this action will use the local bake definition (`source: .`), so
|
||||||
to build from a remote bake definition by default like the [build-push-action](https://github.com/docker/build-push-action)
|
you need to use the [`actions/checkout`](https://github.com/actions/checkout/)
|
||||||
does. This means that you don't need to use the [`actions/checkout`](https://github.com/actions/checkout/)
|
action to check out the repository.
|
||||||
action to check out the repository as [BuildKit](https://docs.docker.com/build/buildkit/)
|
|
||||||
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: Login to DockerHub
|
name: Checkout
|
||||||
uses: docker/login-action@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v4
|
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
|
name: Build and push
|
||||||
uses: docker/bake-action@v7
|
uses: docker/bake-action@v5
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
set: |
|
```
|
||||||
*.tags=user/app:latest
|
|
||||||
|
### Git context
|
||||||
|
|
||||||
|
Git context can be provided using the [`source` input](#inputs). 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/)
|
||||||
|
will do this directly.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bake:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
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@v5
|
||||||
|
with:
|
||||||
|
source: "${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}"
|
||||||
|
push: true
|
||||||
```
|
```
|
||||||
|
|
||||||
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) using the [`source` input](#inputs) alongside
|
[Path context](#path-context) alongside the [`actions/checkout`](https://github.com/actions/checkout/)
|
||||||
the [`actions/checkout`](https://github.com/actions/checkout/) action to remove
|
action to remove this restriction.
|
||||||
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
|
||||||
@@ -82,12 +113,10 @@ to the default Git context:
|
|||||||
```yaml
|
```yaml
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/bake-action@v7
|
uses: docker/bake-action@v5
|
||||||
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`
|
||||||
@@ -102,74 +131,14 @@ another private repository for remote definitions, you can set the
|
|||||||
```yaml
|
```yaml
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/bake-action@v7
|
uses: docker/bake-action@v5
|
||||||
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@v6
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v4
|
|
||||||
with:
|
|
||||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v4
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/bake-action@v7
|
|
||||||
with:
|
|
||||||
source: .
|
|
||||||
push: true
|
|
||||||
set: |
|
|
||||||
*.tags=user/app:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
If you point `source` to a subdirectory, relative paths are resolved from that
|
|
||||||
subdirectory:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/bake-action@v7
|
|
||||||
with:
|
|
||||||
source: ./subdir
|
|
||||||
files: ./docker-bake.hcl
|
|
||||||
```
|
|
||||||
|
|
||||||
For example, if `./subdir/docker-bake.hcl` contains:
|
|
||||||
|
|
||||||
```hcl
|
|
||||||
target "default" {
|
|
||||||
output = ["type=local,dest=./artifacts"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The output will be written to `./subdir/artifacts` in the workspace.
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> More info about `source` semantics in the [Source semantics](#source-semantics) section.
|
|
||||||
|
|
||||||
## Summaries
|
## Summaries
|
||||||
|
|
||||||
This action generates a [job summary](https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/)
|
This action generates a [job summary](https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/)
|
||||||
@@ -184,19 +153,6 @@ 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).
|
||||||
|
|
||||||
@@ -225,11 +181,13 @@ 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`) |
|
| `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/) |
|
| `files` | List/CSV | List of [bake definition files](https://docs.docker.com/build/customize/bake/file-definition/) |
|
||||||
|
| `workdir` | String | Working directory of execution |
|
||||||
|
| `targets` | List/CSV | List of bake targets (`default` target used if empty) |
|
||||||
| `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`) |
|
||||||
@@ -237,9 +195,6 @@ 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`) |
|
||||||
| `source` | String | Build source to use. Supports local path and [remote bake definition](https://docs.docker.com/build/bake/remote-definition/). With a local path, Bake runs from that directory, so all relative paths are resolved from it. See [Source semantics](#source-semantics). |
|
|
||||||
| `targets` | List/CSV | List of bake targets (`default` target used if empty) |
|
|
||||||
| `vars` | List | [Variables](https://docs.docker.com/build/bake/variables/) to set in the Bake definition as list of key-value pair |
|
|
||||||
| `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
|
||||||
@@ -261,24 +216,7 @@ The following outputs are available
|
|||||||
|
|
||||||
## Subactions
|
## Subactions
|
||||||
|
|
||||||
* [`matrix`](subaction/matrix)
|
* [`list-targets`](subaction/list-targets)
|
||||||
|
|
||||||
## Notes
|
|
||||||
|
|
||||||
### Source semantics
|
|
||||||
|
|
||||||
`source` accepts either a Git/remote bake definition (for example `{{defaultContext}}` or `{{defaultContext}}:subdir`)
|
|
||||||
or a local path (for example `.` or `./subdir`). When `source` is a local path,
|
|
||||||
the action runs Bake from that directory (equivalent to `cd <path> && docker buildx bake`).
|
|
||||||
|
|
||||||
This local path mode affects all relative paths resolved by Bake, not only
|
|
||||||
target `context` fields. This includes paths used by local outputs, cache
|
|
||||||
import/export, and `cwd://` references.
|
|
||||||
|
|
||||||
| `source` | Behavior |
|
|
||||||
|-----------------------------------------------------------------------|------------------------------------------------------------------------------------------------|
|
|
||||||
| Git/remote (`{{defaultContext}}`, `https://...git#ref`, `...:subdir`) | Uses [remote bake definition](https://docs.docker.com/build/bake/remote-definition/) behavior. |
|
|
||||||
| Local path (`.`, `./subdir`) | Changes Bake working directory to that path before invoking Bake. |
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,207 @@
|
|||||||
|
import {jest} from '@jest/globals';
|
||||||
|
|
||||||
|
export const context = {
|
||||||
|
repo: {
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'build-push-action'
|
||||||
|
},
|
||||||
|
ref: 'refs/heads/master',
|
||||||
|
runId: 123456789,
|
||||||
|
payload: {
|
||||||
|
after: '860c1904a1ce19322e91ac35af1ab07466440c37',
|
||||||
|
base_ref: null,
|
||||||
|
before: '5f3331d7f7044c18ca9f12c77d961c4d7cf3276a',
|
||||||
|
commits: [
|
||||||
|
{
|
||||||
|
author: {
|
||||||
|
email: 'crazy-max@users.noreply.github.com',
|
||||||
|
name: 'CrazyMax',
|
||||||
|
username: 'crazy-max'
|
||||||
|
},
|
||||||
|
committer: {
|
||||||
|
email: 'crazy-max@users.noreply.github.com',
|
||||||
|
name: 'CrazyMax',
|
||||||
|
username: 'crazy-max'
|
||||||
|
},
|
||||||
|
distinct: true,
|
||||||
|
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
|
||||||
|
message: 'hello dev',
|
||||||
|
timestamp: '2022-04-19T11:27:24+02:00',
|
||||||
|
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
|
||||||
|
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
compare: 'https://github.com/docker/test-docker-action/compare/5f3331d7f704...860c1904a1ce',
|
||||||
|
created: false,
|
||||||
|
deleted: false,
|
||||||
|
forced: false,
|
||||||
|
head_commit: {
|
||||||
|
author: {
|
||||||
|
email: 'crazy-max@users.noreply.github.com',
|
||||||
|
name: 'CrazyMax',
|
||||||
|
username: 'crazy-max'
|
||||||
|
},
|
||||||
|
committer: {
|
||||||
|
email: 'crazy-max@users.noreply.github.com',
|
||||||
|
name: 'CrazyMax',
|
||||||
|
username: 'crazy-max'
|
||||||
|
},
|
||||||
|
distinct: true,
|
||||||
|
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
|
||||||
|
message: 'hello dev',
|
||||||
|
timestamp: '2022-04-19T11:27:24+02:00',
|
||||||
|
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
|
||||||
|
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
|
||||||
|
},
|
||||||
|
organization: {
|
||||||
|
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
|
||||||
|
description: 'Docker helps developers bring their ideas to life by conquering the complexity of app development.',
|
||||||
|
events_url: 'https://api.github.com/orgs/docker/events',
|
||||||
|
hooks_url: 'https://api.github.com/orgs/docker/hooks',
|
||||||
|
id: 5429470,
|
||||||
|
issues_url: 'https://api.github.com/orgs/docker/issues',
|
||||||
|
login: 'docker',
|
||||||
|
members_url: 'https://api.github.com/orgs/docker/members{/member}',
|
||||||
|
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
|
||||||
|
public_members_url: 'https://api.github.com/orgs/docker/public_members{/member}',
|
||||||
|
repos_url: 'https://api.github.com/orgs/docker/repos',
|
||||||
|
url: 'https://api.github.com/orgs/docker'
|
||||||
|
},
|
||||||
|
pusher: {
|
||||||
|
email: 'github@crazymax.dev',
|
||||||
|
name: 'crazy-max'
|
||||||
|
},
|
||||||
|
ref: 'refs/heads/dev',
|
||||||
|
repository: {
|
||||||
|
allow_forking: true,
|
||||||
|
archive_url: 'https://api.github.com/repos/docker/test-docker-action/{archive_format}{/ref}',
|
||||||
|
archived: false,
|
||||||
|
assignees_url: 'https://api.github.com/repos/docker/test-docker-action/assignees{/user}',
|
||||||
|
blobs_url: 'https://api.github.com/repos/docker/test-docker-action/git/blobs{/sha}',
|
||||||
|
branches_url: 'https://api.github.com/repos/docker/test-docker-action/branches{/branch}',
|
||||||
|
clone_url: 'https://github.com/docker/test-docker-action.git',
|
||||||
|
collaborators_url: 'https://api.github.com/repos/docker/test-docker-action/collaborators{/collaborator}',
|
||||||
|
comments_url: 'https://api.github.com/repos/docker/test-docker-action/comments{/number}',
|
||||||
|
commits_url: 'https://api.github.com/repos/docker/test-docker-action/commits{/sha}',
|
||||||
|
compare_url: 'https://api.github.com/repos/docker/test-docker-action/compare/{base}...{head}',
|
||||||
|
contents_url: 'https://api.github.com/repos/docker/test-docker-action/contents/{+path}',
|
||||||
|
contributors_url: 'https://api.github.com/repos/docker/test-docker-action/contributors',
|
||||||
|
created_at: 1596792180,
|
||||||
|
default_branch: 'master',
|
||||||
|
deployments_url: 'https://api.github.com/repos/docker/test-docker-action/deployments',
|
||||||
|
description: 'Test "Docker" Actions',
|
||||||
|
disabled: false,
|
||||||
|
downloads_url: 'https://api.github.com/repos/docker/test-docker-action/downloads',
|
||||||
|
events_url: 'https://api.github.com/repos/docker/test-docker-action/events',
|
||||||
|
fork: false,
|
||||||
|
forks: 1,
|
||||||
|
forks_count: 1,
|
||||||
|
forks_url: 'https://api.github.com/repos/docker/test-docker-action/forks',
|
||||||
|
full_name: 'docker/test-docker-action',
|
||||||
|
git_commits_url: 'https://api.github.com/repos/docker/test-docker-action/git/commits{/sha}',
|
||||||
|
git_refs_url: 'https://api.github.com/repos/docker/test-docker-action/git/refs{/sha}',
|
||||||
|
git_tags_url: 'https://api.github.com/repos/docker/test-docker-action/git/tags{/sha}',
|
||||||
|
git_url: 'git://github.com/docker/test-docker-action.git',
|
||||||
|
has_downloads: true,
|
||||||
|
has_issues: true,
|
||||||
|
has_pages: false,
|
||||||
|
has_projects: true,
|
||||||
|
has_wiki: true,
|
||||||
|
homepage: '',
|
||||||
|
hooks_url: 'https://api.github.com/repos/docker/test-docker-action/hooks',
|
||||||
|
html_url: 'https://github.com/docker/test-docker-action',
|
||||||
|
id: 285789493,
|
||||||
|
is_template: false,
|
||||||
|
issue_comment_url: 'https://api.github.com/repos/docker/test-docker-action/issues/comments{/number}',
|
||||||
|
issue_events_url: 'https://api.github.com/repos/docker/test-docker-action/issues/events{/number}',
|
||||||
|
issues_url: 'https://api.github.com/repos/docker/test-docker-action/issues{/number}',
|
||||||
|
keys_url: 'https://api.github.com/repos/docker/test-docker-action/keys{/key_id}',
|
||||||
|
labels_url: 'https://api.github.com/repos/docker/test-docker-action/labels{/name}',
|
||||||
|
language: 'JavaScript',
|
||||||
|
languages_url: 'https://api.github.com/repos/docker/test-docker-action/languages',
|
||||||
|
license: {
|
||||||
|
key: 'mit',
|
||||||
|
name: 'MIT License',
|
||||||
|
node_id: 'MDc6TGljZW5zZTEz',
|
||||||
|
spdx_id: 'MIT',
|
||||||
|
url: 'https://api.github.com/licenses/mit'
|
||||||
|
},
|
||||||
|
master_branch: 'master',
|
||||||
|
merges_url: 'https://api.github.com/repos/docker/test-docker-action/merges',
|
||||||
|
milestones_url: 'https://api.github.com/repos/docker/test-docker-action/milestones{/number}',
|
||||||
|
mirror_url: null,
|
||||||
|
name: 'test-docker-action',
|
||||||
|
node_id: 'MDEwOlJlcG9zaXRvcnkyODU3ODk0OTM=',
|
||||||
|
notifications_url: 'https://api.github.com/repos/docker/test-docker-action/notifications{?since,all,participating}',
|
||||||
|
open_issues: 6,
|
||||||
|
open_issues_count: 6,
|
||||||
|
organization: 'docker',
|
||||||
|
owner: {
|
||||||
|
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
|
||||||
|
email: 'info@docker.com',
|
||||||
|
events_url: 'https://api.github.com/users/docker/events{/privacy}',
|
||||||
|
followers_url: 'https://api.github.com/users/docker/followers',
|
||||||
|
following_url: 'https://api.github.com/users/docker/following{/other_user}',
|
||||||
|
gists_url: 'https://api.github.com/users/docker/gists{/gist_id}',
|
||||||
|
gravatar_id: '',
|
||||||
|
html_url: 'https://github.com/docker',
|
||||||
|
id: 5429470,
|
||||||
|
login: 'docker',
|
||||||
|
name: 'docker',
|
||||||
|
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
|
||||||
|
organizations_url: 'https://api.github.com/users/docker/orgs',
|
||||||
|
received_events_url: 'https://api.github.com/users/docker/received_events',
|
||||||
|
repos_url: 'https://api.github.com/users/docker/repos',
|
||||||
|
site_admin: false,
|
||||||
|
starred_url: 'https://api.github.com/users/docker/starred{/owner}{/repo}',
|
||||||
|
subscriptions_url: 'https://api.github.com/users/docker/subscriptions',
|
||||||
|
type: 'Organization',
|
||||||
|
url: 'https://api.github.com/users/docker'
|
||||||
|
},
|
||||||
|
private: true,
|
||||||
|
pulls_url: 'https://api.github.com/repos/docker/test-docker-action/pulls{/number}',
|
||||||
|
pushed_at: 1650360446,
|
||||||
|
releases_url: 'https://api.github.com/repos/docker/test-docker-action/releases{/id}',
|
||||||
|
size: 796,
|
||||||
|
ssh_url: 'git@github.com:docker/test-docker-action.git',
|
||||||
|
stargazers: 0,
|
||||||
|
stargazers_count: 0,
|
||||||
|
stargazers_url: 'https://api.github.com/repos/docker/test-docker-action/stargazers',
|
||||||
|
statuses_url: 'https://api.github.com/repos/docker/test-docker-action/statuses/{sha}',
|
||||||
|
subscribers_url: 'https://api.github.com/repos/docker/test-docker-action/subscribers',
|
||||||
|
subscription_url: 'https://api.github.com/repos/docker/test-docker-action/subscription',
|
||||||
|
svn_url: 'https://github.com/docker/test-docker-action',
|
||||||
|
tags_url: 'https://api.github.com/repos/docker/test-docker-action/tags',
|
||||||
|
teams_url: 'https://api.github.com/repos/docker/test-docker-action/teams',
|
||||||
|
topics: [],
|
||||||
|
trees_url: 'https://api.github.com/repos/docker/test-docker-action/git/trees{/sha}',
|
||||||
|
updated_at: '2022-04-19T09:05:09Z',
|
||||||
|
url: 'https://github.com/docker/test-docker-action',
|
||||||
|
visibility: 'private',
|
||||||
|
watchers: 0,
|
||||||
|
watchers_count: 0
|
||||||
|
},
|
||||||
|
sender: {
|
||||||
|
avatar_url: 'https://avatars.githubusercontent.com/u/1951866?v=4',
|
||||||
|
events_url: 'https://api.github.com/users/crazy-max/events{/privacy}',
|
||||||
|
followers_url: 'https://api.github.com/users/crazy-max/followers',
|
||||||
|
following_url: 'https://api.github.com/users/crazy-max/following{/other_user}',
|
||||||
|
gists_url: 'https://api.github.com/users/crazy-max/gists{/gist_id}',
|
||||||
|
gravatar_id: '',
|
||||||
|
html_url: 'https://github.com/crazy-max',
|
||||||
|
id: 1951866,
|
||||||
|
login: 'crazy-max',
|
||||||
|
node_id: 'MDQ6VXNlcjE5NTE4NjY=',
|
||||||
|
organizations_url: 'https://api.github.com/users/crazy-max/orgs',
|
||||||
|
received_events_url: 'https://api.github.com/users/crazy-max/received_events',
|
||||||
|
repos_url: 'https://api.github.com/users/crazy-max/repos',
|
||||||
|
site_admin: false,
|
||||||
|
starred_url: 'https://api.github.com/users/crazy-max/starred{/owner}{/repo}',
|
||||||
|
subscriptions_url: 'https://api.github.com/users/crazy-max/subscriptions',
|
||||||
|
type: 'User',
|
||||||
|
url: 'https://api.github.com/users/crazy-max'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getOctokit = jest.fn();
|
||||||
+128
-227
@@ -1,96 +1,127 @@
|
|||||||
import {afterEach, beforeEach, describe, expect, test, vi} from 'vitest';
|
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
import {Bake} from '@docker/actions-toolkit/lib/buildx/bake.js';
|
import {Bake} from '@docker/actions-toolkit/lib/buildx/bake';
|
||||||
import {Build} from '@docker/actions-toolkit/lib/buildx/build.js';
|
import {Builder} from '@docker/actions-toolkit/lib/buildx/builder';
|
||||||
import {Builder} from '@docker/actions-toolkit/lib/buildx/builder.js';
|
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
|
||||||
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx.js';
|
import {Context} from '@docker/actions-toolkit/lib/context';
|
||||||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';
|
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit.js';
|
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
||||||
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||||
|
|
||||||
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake.js';
|
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
||||||
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder.js';
|
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder';
|
||||||
|
import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github';
|
||||||
|
|
||||||
import * as context from '../src/context.js';
|
import * as context from '../src/context';
|
||||||
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'context-'));
|
const tmpDir = path.join('/tmp', '.docker-bake-action-jest');
|
||||||
const fixturesDir = path.join(__dirname, 'fixtures');
|
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||||
|
|
||||||
vi.spyOn(Docker, 'isAvailable').mockImplementation(async (): Promise<boolean> => {
|
import repoFixture from './fixtures/github-repo.json';
|
||||||
|
jest.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
|
||||||
|
return <Promise<GitHubRepo>>(repoFixture as unknown);
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||||
|
if (!fs.existsSync(tmpDir)) {
|
||||||
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
|
}
|
||||||
|
return tmpDir;
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||||
|
return tmpName;
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.spyOn(Docker, 'isAvailable').mockImplementation(async (): Promise<boolean> => {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
const metadataJson = path.join(tmpDir, 'metadata.json');
|
const metadataJson = path.join(tmpDir, 'metadata.json');
|
||||||
vi.spyOn(Bake.prototype, 'getMetadataFilePath').mockImplementation((): string => {
|
jest.spyOn(Bake.prototype, 'getMetadataFilePath').mockImplementation((): string => {
|
||||||
return metadataJson;
|
return metadataJson;
|
||||||
});
|
});
|
||||||
|
|
||||||
type BuilderInfoFixture = Omit<BuilderInfo, 'lastActivity'> & {lastActivity: string};
|
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
||||||
const builderInfoFixture = <BuilderInfoFixture>JSON.parse(fs.readFileSync(path.join(fixturesDir, 'builder-info.json'), {encoding: 'utf-8'}).trim());
|
|
||||||
vi.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
|
||||||
return {
|
return {
|
||||||
...builderInfoFixture,
|
name: 'builder2',
|
||||||
lastActivity: new Date(builderInfoFixture.lastActivity)
|
driver: 'docker-container',
|
||||||
|
lastActivity: new Date('2023-01-16 09:45:23 +0000 UTC'),
|
||||||
|
nodes: [
|
||||||
|
{
|
||||||
|
buildkit: 'v0.11.0',
|
||||||
|
'buildkitd-flags': '--debug --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
|
||||||
|
'driver-opts': ['BUILDKIT_STEP_LOG_MAX_SIZE=10485760', 'BUILDKIT_STEP_LOG_MAX_SPEED=10485760', 'JAEGER_TRACE=localhost:6831', 'image=moby/buildkit:latest', 'network=host'],
|
||||||
|
endpoint: 'unix:///var/run/docker.sock',
|
||||||
|
name: 'builder20',
|
||||||
|
platforms: 'linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6',
|
||||||
|
status: 'running'
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
vi.spyOn(Bake.prototype, 'getDefinition').mockImplementation(async (): Promise<BakeDefinition> => {
|
jest.spyOn(Bake.prototype, 'getDefinition').mockImplementation(async (): Promise<BakeDefinition> => {
|
||||||
return <BakeDefinition>JSON.parse(fs.readFileSync(path.join(fixturesDir, 'bake-def.json'), {encoding: 'utf-8'}).trim());
|
return JSON.parse(`{
|
||||||
});
|
"group": {
|
||||||
|
"default": {
|
||||||
describe('getInputs', () => {
|
"targets": [
|
||||||
const originalEnv = process.env;
|
"validate"
|
||||||
|
]
|
||||||
beforeEach(() => {
|
},
|
||||||
process.env = Object.keys(process.env).reduce((object, key) => {
|
"validate": {
|
||||||
if (!key.startsWith('INPUT_')) {
|
"targets": [
|
||||||
object[key] = process.env[key];
|
"lint",
|
||||||
|
"validate-vendor",
|
||||||
|
"validate-docs"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
return object;
|
},
|
||||||
}, {});
|
"target": {
|
||||||
});
|
"lint": {
|
||||||
|
"context": ".",
|
||||||
afterEach(() => {
|
"dockerfile": "./hack/dockerfiles/lint.Dockerfile",
|
||||||
process.env = originalEnv;
|
"args": {
|
||||||
});
|
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||||
|
"GO_VERSION": "1.20"
|
||||||
function setRequiredBooleanInputs(): void {
|
},
|
||||||
setInput('no-cache', 'false');
|
"output": [
|
||||||
setInput('pull', 'false');
|
"type=cacheonly"
|
||||||
setInput('load', 'false');
|
]
|
||||||
setInput('push', 'false');
|
},
|
||||||
|
"validate-docs": {
|
||||||
|
"context": ".",
|
||||||
|
"dockerfile": "./hack/dockerfiles/docs.Dockerfile",
|
||||||
|
"args": {
|
||||||
|
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||||
|
"BUILDX_EXPERIMENTAL": "1",
|
||||||
|
"FORMATS": "md",
|
||||||
|
"GO_VERSION": "1.20"
|
||||||
|
},
|
||||||
|
"target": "validate",
|
||||||
|
"output": [
|
||||||
|
"type=cacheonly"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"validate-vendor": {
|
||||||
|
"context": ".",
|
||||||
|
"dockerfile": "./hack/dockerfiles/vendor.Dockerfile",
|
||||||
|
"args": {
|
||||||
|
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||||
|
"GO_VERSION": "1.20"
|
||||||
|
},
|
||||||
|
"target": "validate",
|
||||||
|
"output": [
|
||||||
|
"type=cacheonly"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
test('uses Build git context when source input is empty', async () => {
|
}`) as BakeDefinition;
|
||||||
const gitContext = 'https://github.com/docker/bake-action.git?ref=refs/heads/master&checksum=0123456789abcdef';
|
|
||||||
const gitContextSpy = vi.spyOn(Build.prototype, 'gitContext').mockResolvedValue(gitContext);
|
|
||||||
setRequiredBooleanInputs();
|
|
||||||
const inputs = await context.getInputs();
|
|
||||||
expect(inputs.source).toEqual({
|
|
||||||
remoteRef: gitContext
|
|
||||||
});
|
|
||||||
expect(gitContextSpy).toHaveBeenCalledTimes(1);
|
|
||||||
gitContextSpy.mockRestore();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('renders defaultContext source templates from Build git context', async () => {
|
|
||||||
const gitContext = 'https://github.com/docker/bake-action.git#refs/heads/master';
|
|
||||||
const gitContextSpy = vi.spyOn(Build.prototype, 'gitContext').mockResolvedValue(gitContext);
|
|
||||||
setRequiredBooleanInputs();
|
|
||||||
setInput('source', '{{defaultContext}}:subdir');
|
|
||||||
const inputs = await context.getInputs();
|
|
||||||
expect(inputs.source).toEqual({
|
|
||||||
remoteRef: `${gitContext}:subdir`
|
|
||||||
});
|
|
||||||
expect(gitContextSpy).toHaveBeenCalledTimes(1);
|
|
||||||
gitContextSpy.mockRestore();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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_')) {
|
||||||
@@ -99,9 +130,6 @@ describe('getArgs', () => {
|
|||||||
return object;
|
return object;
|
||||||
}, {});
|
}, {});
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
|
||||||
process.env = originalEnv;
|
|
||||||
});
|
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each([
|
test.each([
|
||||||
@@ -109,7 +137,6 @@ 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'],
|
||||||
@@ -117,14 +144,12 @@ 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'],
|
||||||
@@ -133,14 +158,12 @@ 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'],
|
||||||
@@ -151,14 +174,12 @@ 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'],
|
||||||
@@ -170,14 +191,12 @@ 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'],
|
||||||
@@ -186,17 +205,13 @@ describe('getArgs', () => {
|
|||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`,
|
"--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/bake-action/actions/runs/123456789/attempts/1`,
|
]
|
||||||
'--set', `validate-vendor.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-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'],
|
||||||
@@ -206,15 +221,13 @@ describe('getArgs', () => {
|
|||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", `builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`
|
"--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'],
|
||||||
@@ -224,15 +237,13 @@ describe('getArgs', () => {
|
|||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
"--provenance", `mode=max,builder-id=https://github.com/docker/bake-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,
|
||||||
'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'],
|
||||||
@@ -243,14 +254,12 @@ 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'],
|
||||||
@@ -261,14 +270,12 @@ 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'],
|
||||||
@@ -281,18 +288,14 @@ 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,
|
||||||
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`,
|
'--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/bake-action/actions/runs/123456789/attempts/1`,
|
|
||||||
'--set', `validate-vendor.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-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'],
|
||||||
@@ -304,17 +307,15 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--set', `*.labels.foo=bar=#baz`,
|
'--set', `*.labels.foo=bar=#baz`,
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`,
|
'--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/bake-action/actions/runs/123456789/attempts/1`,
|
|
||||||
'--set', `validate-vendor.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-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'],
|
||||||
@@ -323,20 +324,16 @@ describe('getArgs', () => {
|
|||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'bake',
|
'bake',
|
||||||
'https://github.com/docker/bake-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,
|
||||||
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`,
|
'--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/bake-action/actions/runs/123456789/attempts/1`,
|
]
|
||||||
'--set', `validate-vendor.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`
|
|
||||||
],
|
|
||||||
undefined
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
12,
|
12,
|
||||||
'0.17.0',
|
'0.17.0',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['source', '.'],
|
|
||||||
['allow', 'network.host'],
|
['allow', 'network.host'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
@@ -347,113 +344,17 @@ describe('getArgs', () => {
|
|||||||
'bake',
|
'bake',
|
||||||
'--allow', 'network.host',
|
'--allow', 'network.host',
|
||||||
'--metadata-file', metadataJson,
|
'--metadata-file', metadataJson,
|
||||||
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`,
|
"--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/bake-action/actions/runs/123456789/attempts/1`,
|
]
|
||||||
'--set', `validate-vendor.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-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/bake-action.git#refs/heads/master:subdir',
|
|
||||||
'--file', './foo.hcl',
|
|
||||||
'--metadata-file', metadataJson,
|
|
||||||
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`,
|
|
||||||
'--set', `validate-docs.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`,
|
|
||||||
'--set', `validate-vendor.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-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']
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
15,
|
|
||||||
'0.29.0',
|
|
||||||
new Map<string, string>([
|
|
||||||
['load', 'false'],
|
|
||||||
['no-cache', 'false'],
|
|
||||||
['push', 'false'],
|
|
||||||
['pull', 'false'],
|
|
||||||
['files', './foo.hcl'],
|
|
||||||
]),
|
|
||||||
[
|
|
||||||
'bake',
|
|
||||||
'https://github.com/docker/bake-action.git?ref=refs/heads/master',
|
|
||||||
'--allow', 'fs=*',
|
|
||||||
'--file', './foo.hcl',
|
|
||||||
'--metadata-file', metadataJson,
|
|
||||||
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`,
|
|
||||||
'--set', `validate-docs.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`,
|
|
||||||
'--set', `validate-vendor.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`
|
|
||||||
],
|
|
||||||
new Map<string, string>([
|
|
||||||
['BUILDX_SEND_GIT_QUERY_AS_INPUT', 'true']
|
|
||||||
])
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16,
|
|
||||||
'0.28.0',
|
|
||||||
new Map<string, string>([
|
|
||||||
['load', 'false'],
|
|
||||||
['no-cache', 'false'],
|
|
||||||
['push', 'false'],
|
|
||||||
['pull', 'false'],
|
|
||||||
['files', './foo.hcl'],
|
|
||||||
]),
|
|
||||||
[
|
|
||||||
'bake',
|
|
||||||
'https://github.com/docker/bake-action.git#refs/heads/master',
|
|
||||||
'--allow', 'fs=*',
|
|
||||||
'--file', './foo.hcl',
|
|
||||||
'--metadata-file', metadataJson,
|
|
||||||
'--set', `lint.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`,
|
|
||||||
'--set', `validate-docs.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`,
|
|
||||||
'--set', `validate-vendor.attest=type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/bake-action/actions/runs/123456789/attempts/1`
|
|
||||||
],
|
|
||||||
new Map<string, string>([
|
|
||||||
['BUILDX_SEND_GIT_QUERY_AS_INPUT', 'true']
|
|
||||||
])
|
|
||||||
],
|
],
|
||||||
])(
|
])(
|
||||||
'[%d] given %o with %o as inputs, returns %o',
|
'[%d] given %p with %p as inputs, returns %p',
|
||||||
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>, envs: Map<string, string> | undefined) => {
|
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {
|
||||||
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);
|
||||||
});
|
});
|
||||||
const toolkit = new Toolkit();
|
const toolkit = new Toolkit();
|
||||||
vi.spyOn(Buildx.prototype, 'version').mockImplementation(async (): Promise<string> => {
|
jest.spyOn(Buildx.prototype, 'version').mockImplementation(async (): Promise<string> => {
|
||||||
return buildxVersion;
|
return buildxVersion;
|
||||||
});
|
});
|
||||||
const inp = await context.getInputs();
|
const inp = await context.getInputs();
|
||||||
@@ -466,11 +367,11 @@ describe('getArgs', () => {
|
|||||||
provenance: inp.provenance,
|
provenance: inp.provenance,
|
||||||
push: inp.push,
|
push: inp.push,
|
||||||
sbom: inp.sbom,
|
sbom: inp.sbom,
|
||||||
source: inp.source.remoteRef,
|
source: inp.source,
|
||||||
targets: inp.targets
|
targets: inp.targets
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cwd: inp.source.workdir,
|
cwd: inp.workdir
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const res = await context.getArgs(inp, definition, toolkit);
|
const res = await context.getArgs(inp, definition, toolkit);
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
{
|
|
||||||
"group": {
|
|
||||||
"default": {
|
|
||||||
"targets": [
|
|
||||||
"validate"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"validate": {
|
|
||||||
"targets": [
|
|
||||||
"lint",
|
|
||||||
"validate-vendor",
|
|
||||||
"validate-docs"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"target": {
|
|
||||||
"lint": {
|
|
||||||
"context": ".",
|
|
||||||
"dockerfile": "./hack/dockerfiles/lint.Dockerfile",
|
|
||||||
"args": {
|
|
||||||
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
|
||||||
"GO_VERSION": "1.20"
|
|
||||||
},
|
|
||||||
"output": [
|
|
||||||
"type=cacheonly"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"validate-docs": {
|
|
||||||
"context": ".",
|
|
||||||
"dockerfile": "./hack/dockerfiles/docs.Dockerfile",
|
|
||||||
"args": {
|
|
||||||
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
|
||||||
"BUILDX_EXPERIMENTAL": "1",
|
|
||||||
"FORMATS": "md",
|
|
||||||
"GO_VERSION": "1.20"
|
|
||||||
},
|
|
||||||
"target": "validate",
|
|
||||||
"output": [
|
|
||||||
"type=cacheonly"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"validate-vendor": {
|
|
||||||
"context": ".",
|
|
||||||
"dockerfile": "./hack/dockerfiles/vendor.Dockerfile",
|
|
||||||
"args": {
|
|
||||||
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
|
||||||
"GO_VERSION": "1.20"
|
|
||||||
},
|
|
||||||
"target": "validate",
|
|
||||||
"output": [
|
|
||||||
"type=cacheonly"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "builder2",
|
|
||||||
"driver": "docker-container",
|
|
||||||
"lastActivity": "2023-01-16 09:45:23 +0000 UTC",
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"buildkit": "v0.11.0",
|
|
||||||
"buildkitd-flags": "--debug --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host",
|
|
||||||
"driver-opts": [
|
|
||||||
"BUILDKIT_STEP_LOG_MAX_SIZE=10485760",
|
|
||||||
"BUILDKIT_STEP_LOG_MAX_SPEED=10485760",
|
|
||||||
"JAEGER_TRACE=localhost:6831",
|
|
||||||
"image=moby/buildkit:latest",
|
|
||||||
"network=host"
|
|
||||||
],
|
|
||||||
"endpoint": "unix:///var/run/docker.sock",
|
|
||||||
"name": "builder20",
|
|
||||||
"platforms": "linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6",
|
|
||||||
"status": "running"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,362 @@
|
|||||||
|
{
|
||||||
|
"id": 1296269,
|
||||||
|
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
|
||||||
|
"name": "Hello-World",
|
||||||
|
"full_name": "octocat/Hello-World",
|
||||||
|
"owner": {
|
||||||
|
"login": "octocat",
|
||||||
|
"id": 1,
|
||||||
|
"node_id": "MDQ6VXNlcjE=",
|
||||||
|
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/octocat",
|
||||||
|
"html_url": "https://github.com/octocat",
|
||||||
|
"followers_url": "https://api.github.com/users/octocat/followers",
|
||||||
|
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
||||||
|
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
||||||
|
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
||||||
|
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
||||||
|
"repos_url": "https://api.github.com/users/octocat/repos",
|
||||||
|
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
||||||
|
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
||||||
|
"type": "User",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"private": false,
|
||||||
|
"html_url": "https://github.com/octocat/Hello-World",
|
||||||
|
"description": "This your first repo!",
|
||||||
|
"fork": false,
|
||||||
|
"url": "https://api.github.com/repos/octocat/Hello-World",
|
||||||
|
"archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
|
||||||
|
"assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}",
|
||||||
|
"blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
|
||||||
|
"branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}",
|
||||||
|
"collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
|
||||||
|
"comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}",
|
||||||
|
"commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}",
|
||||||
|
"compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
|
||||||
|
"contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}",
|
||||||
|
"contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors",
|
||||||
|
"deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments",
|
||||||
|
"downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads",
|
||||||
|
"events_url": "http://api.github.com/repos/octocat/Hello-World/events",
|
||||||
|
"forks_url": "http://api.github.com/repos/octocat/Hello-World/forks",
|
||||||
|
"git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
|
||||||
|
"git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
|
||||||
|
"git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
|
||||||
|
"git_url": "git:github.com/octocat/Hello-World.git",
|
||||||
|
"issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
|
||||||
|
"issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
|
||||||
|
"issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}",
|
||||||
|
"keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
|
||||||
|
"labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}",
|
||||||
|
"languages_url": "http://api.github.com/repos/octocat/Hello-World/languages",
|
||||||
|
"merges_url": "http://api.github.com/repos/octocat/Hello-World/merges",
|
||||||
|
"milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}",
|
||||||
|
"notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
|
||||||
|
"pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}",
|
||||||
|
"releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}",
|
||||||
|
"ssh_url": "git@github.com:octocat/Hello-World.git",
|
||||||
|
"stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers",
|
||||||
|
"statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
|
||||||
|
"subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers",
|
||||||
|
"subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription",
|
||||||
|
"tags_url": "http://api.github.com/repos/octocat/Hello-World/tags",
|
||||||
|
"teams_url": "http://api.github.com/repos/octocat/Hello-World/teams",
|
||||||
|
"trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
|
||||||
|
"clone_url": "https://github.com/octocat/Hello-World.git",
|
||||||
|
"mirror_url": "git:git.example.com/octocat/Hello-World",
|
||||||
|
"hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks",
|
||||||
|
"svn_url": "https://svn.github.com/octocat/Hello-World",
|
||||||
|
"homepage": "https://github.com",
|
||||||
|
"language": null,
|
||||||
|
"forks_count": 9,
|
||||||
|
"stargazers_count": 80,
|
||||||
|
"watchers_count": 80,
|
||||||
|
"size": 108,
|
||||||
|
"default_branch": "master",
|
||||||
|
"open_issues_count": 0,
|
||||||
|
"is_template": true,
|
||||||
|
"topics": [
|
||||||
|
"octocat",
|
||||||
|
"atom",
|
||||||
|
"electron",
|
||||||
|
"api"
|
||||||
|
],
|
||||||
|
"has_issues": true,
|
||||||
|
"has_projects": true,
|
||||||
|
"has_wiki": true,
|
||||||
|
"has_pages": false,
|
||||||
|
"has_downloads": true,
|
||||||
|
"archived": false,
|
||||||
|
"disabled": false,
|
||||||
|
"visibility": "public",
|
||||||
|
"pushed_at": "2011-01-26T19:06:43Z",
|
||||||
|
"created_at": "2011-01-26T19:01:12Z",
|
||||||
|
"updated_at": "2011-01-26T19:14:43Z",
|
||||||
|
"permissions": {
|
||||||
|
"pull": true,
|
||||||
|
"triage": true,
|
||||||
|
"push": false,
|
||||||
|
"maintain": false,
|
||||||
|
"admin": false
|
||||||
|
},
|
||||||
|
"allow_rebase_merge": true,
|
||||||
|
"template_repository": null,
|
||||||
|
"temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O",
|
||||||
|
"allow_squash_merge": true,
|
||||||
|
"delete_branch_on_merge": true,
|
||||||
|
"allow_merge_commit": true,
|
||||||
|
"subscribers_count": 42,
|
||||||
|
"network_count": 0,
|
||||||
|
"license": {
|
||||||
|
"key": "mit",
|
||||||
|
"name": "MIT License",
|
||||||
|
"spdx_id": "MIT",
|
||||||
|
"url": "https://api.github.com/licenses/mit",
|
||||||
|
"node_id": "MDc6TGljZW5zZW1pdA=="
|
||||||
|
},
|
||||||
|
"organization": {
|
||||||
|
"login": "octocat",
|
||||||
|
"id": 1,
|
||||||
|
"node_id": "MDQ6VXNlcjE=",
|
||||||
|
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/octocat",
|
||||||
|
"html_url": "https://github.com/octocat",
|
||||||
|
"followers_url": "https://api.github.com/users/octocat/followers",
|
||||||
|
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
||||||
|
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
||||||
|
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
||||||
|
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
||||||
|
"repos_url": "https://api.github.com/users/octocat/repos",
|
||||||
|
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
||||||
|
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
||||||
|
"type": "Organization",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"parent": {
|
||||||
|
"id": 1296269,
|
||||||
|
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
|
||||||
|
"name": "Hello-World",
|
||||||
|
"full_name": "octocat/Hello-World",
|
||||||
|
"owner": {
|
||||||
|
"login": "octocat",
|
||||||
|
"id": 1,
|
||||||
|
"node_id": "MDQ6VXNlcjE=",
|
||||||
|
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/octocat",
|
||||||
|
"html_url": "https://github.com/octocat",
|
||||||
|
"followers_url": "https://api.github.com/users/octocat/followers",
|
||||||
|
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
||||||
|
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
||||||
|
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
||||||
|
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
||||||
|
"repos_url": "https://api.github.com/users/octocat/repos",
|
||||||
|
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
||||||
|
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
||||||
|
"type": "User",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"private": false,
|
||||||
|
"html_url": "https://github.com/octocat/Hello-World",
|
||||||
|
"description": "This your first repo!",
|
||||||
|
"fork": false,
|
||||||
|
"url": "https://api.github.com/repos/octocat/Hello-World",
|
||||||
|
"archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
|
||||||
|
"assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}",
|
||||||
|
"blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
|
||||||
|
"branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}",
|
||||||
|
"collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
|
||||||
|
"comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}",
|
||||||
|
"commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}",
|
||||||
|
"compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
|
||||||
|
"contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}",
|
||||||
|
"contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors",
|
||||||
|
"deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments",
|
||||||
|
"downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads",
|
||||||
|
"events_url": "http://api.github.com/repos/octocat/Hello-World/events",
|
||||||
|
"forks_url": "http://api.github.com/repos/octocat/Hello-World/forks",
|
||||||
|
"git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
|
||||||
|
"git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
|
||||||
|
"git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
|
||||||
|
"git_url": "git:github.com/octocat/Hello-World.git",
|
||||||
|
"issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
|
||||||
|
"issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
|
||||||
|
"issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}",
|
||||||
|
"keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
|
||||||
|
"labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}",
|
||||||
|
"languages_url": "http://api.github.com/repos/octocat/Hello-World/languages",
|
||||||
|
"merges_url": "http://api.github.com/repos/octocat/Hello-World/merges",
|
||||||
|
"milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}",
|
||||||
|
"notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
|
||||||
|
"pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}",
|
||||||
|
"releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}",
|
||||||
|
"ssh_url": "git@github.com:octocat/Hello-World.git",
|
||||||
|
"stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers",
|
||||||
|
"statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
|
||||||
|
"subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers",
|
||||||
|
"subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription",
|
||||||
|
"tags_url": "http://api.github.com/repos/octocat/Hello-World/tags",
|
||||||
|
"teams_url": "http://api.github.com/repos/octocat/Hello-World/teams",
|
||||||
|
"trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
|
||||||
|
"clone_url": "https://github.com/octocat/Hello-World.git",
|
||||||
|
"mirror_url": "git:git.example.com/octocat/Hello-World",
|
||||||
|
"hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks",
|
||||||
|
"svn_url": "https://svn.github.com/octocat/Hello-World",
|
||||||
|
"homepage": "https://github.com",
|
||||||
|
"language": null,
|
||||||
|
"forks_count": 9,
|
||||||
|
"stargazers_count": 80,
|
||||||
|
"watchers_count": 80,
|
||||||
|
"size": 108,
|
||||||
|
"default_branch": "master",
|
||||||
|
"open_issues_count": 0,
|
||||||
|
"is_template": true,
|
||||||
|
"topics": [
|
||||||
|
"octocat",
|
||||||
|
"atom",
|
||||||
|
"electron",
|
||||||
|
"api"
|
||||||
|
],
|
||||||
|
"has_issues": true,
|
||||||
|
"has_projects": true,
|
||||||
|
"has_wiki": true,
|
||||||
|
"has_pages": false,
|
||||||
|
"has_downloads": true,
|
||||||
|
"archived": false,
|
||||||
|
"disabled": false,
|
||||||
|
"visibility": "public",
|
||||||
|
"pushed_at": "2011-01-26T19:06:43Z",
|
||||||
|
"created_at": "2011-01-26T19:01:12Z",
|
||||||
|
"updated_at": "2011-01-26T19:14:43Z",
|
||||||
|
"permissions": {
|
||||||
|
"admin": false,
|
||||||
|
"push": false,
|
||||||
|
"pull": true
|
||||||
|
},
|
||||||
|
"allow_rebase_merge": true,
|
||||||
|
"template_repository": null,
|
||||||
|
"temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O",
|
||||||
|
"allow_squash_merge": true,
|
||||||
|
"delete_branch_on_merge": true,
|
||||||
|
"allow_merge_commit": true,
|
||||||
|
"subscribers_count": 42,
|
||||||
|
"network_count": 0
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"id": 1296269,
|
||||||
|
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
|
||||||
|
"name": "Hello-World",
|
||||||
|
"full_name": "octocat/Hello-World",
|
||||||
|
"owner": {
|
||||||
|
"login": "octocat",
|
||||||
|
"id": 1,
|
||||||
|
"node_id": "MDQ6VXNlcjE=",
|
||||||
|
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/octocat",
|
||||||
|
"html_url": "https://github.com/octocat",
|
||||||
|
"followers_url": "https://api.github.com/users/octocat/followers",
|
||||||
|
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
||||||
|
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
||||||
|
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
||||||
|
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
||||||
|
"repos_url": "https://api.github.com/users/octocat/repos",
|
||||||
|
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
||||||
|
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
||||||
|
"type": "User",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"private": false,
|
||||||
|
"html_url": "https://github.com/octocat/Hello-World",
|
||||||
|
"description": "This your first repo!",
|
||||||
|
"fork": false,
|
||||||
|
"url": "https://api.github.com/repos/octocat/Hello-World",
|
||||||
|
"archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
|
||||||
|
"assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}",
|
||||||
|
"blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
|
||||||
|
"branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}",
|
||||||
|
"collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
|
||||||
|
"comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}",
|
||||||
|
"commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}",
|
||||||
|
"compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
|
||||||
|
"contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}",
|
||||||
|
"contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors",
|
||||||
|
"deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments",
|
||||||
|
"downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads",
|
||||||
|
"events_url": "http://api.github.com/repos/octocat/Hello-World/events",
|
||||||
|
"forks_url": "http://api.github.com/repos/octocat/Hello-World/forks",
|
||||||
|
"git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
|
||||||
|
"git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
|
||||||
|
"git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
|
||||||
|
"git_url": "git:github.com/octocat/Hello-World.git",
|
||||||
|
"issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
|
||||||
|
"issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
|
||||||
|
"issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}",
|
||||||
|
"keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
|
||||||
|
"labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}",
|
||||||
|
"languages_url": "http://api.github.com/repos/octocat/Hello-World/languages",
|
||||||
|
"merges_url": "http://api.github.com/repos/octocat/Hello-World/merges",
|
||||||
|
"milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}",
|
||||||
|
"notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
|
||||||
|
"pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}",
|
||||||
|
"releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}",
|
||||||
|
"ssh_url": "git@github.com:octocat/Hello-World.git",
|
||||||
|
"stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers",
|
||||||
|
"statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
|
||||||
|
"subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers",
|
||||||
|
"subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription",
|
||||||
|
"tags_url": "http://api.github.com/repos/octocat/Hello-World/tags",
|
||||||
|
"teams_url": "http://api.github.com/repos/octocat/Hello-World/teams",
|
||||||
|
"trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
|
||||||
|
"clone_url": "https://github.com/octocat/Hello-World.git",
|
||||||
|
"mirror_url": "git:git.example.com/octocat/Hello-World",
|
||||||
|
"hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks",
|
||||||
|
"svn_url": "https://svn.github.com/octocat/Hello-World",
|
||||||
|
"homepage": "https://github.com",
|
||||||
|
"language": null,
|
||||||
|
"forks_count": 9,
|
||||||
|
"stargazers_count": 80,
|
||||||
|
"watchers_count": 80,
|
||||||
|
"size": 108,
|
||||||
|
"default_branch": "master",
|
||||||
|
"open_issues_count": 0,
|
||||||
|
"is_template": true,
|
||||||
|
"topics": [
|
||||||
|
"octocat",
|
||||||
|
"atom",
|
||||||
|
"electron",
|
||||||
|
"api"
|
||||||
|
],
|
||||||
|
"has_issues": true,
|
||||||
|
"has_projects": true,
|
||||||
|
"has_wiki": true,
|
||||||
|
"has_pages": false,
|
||||||
|
"has_downloads": true,
|
||||||
|
"archived": false,
|
||||||
|
"disabled": false,
|
||||||
|
"visibility": "public",
|
||||||
|
"pushed_at": "2011-01-26T19:06:43Z",
|
||||||
|
"created_at": "2011-01-26T19:01:12Z",
|
||||||
|
"updated_at": "2011-01-26T19:14:43Z",
|
||||||
|
"permissions": {
|
||||||
|
"admin": false,
|
||||||
|
"push": false,
|
||||||
|
"pull": true
|
||||||
|
},
|
||||||
|
"allow_rebase_merge": true,
|
||||||
|
"template_repository": null,
|
||||||
|
"temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O",
|
||||||
|
"allow_squash_merge": true,
|
||||||
|
"delete_branch_on_merge": true,
|
||||||
|
"allow_merge_commit": true,
|
||||||
|
"subscribers_count": 42,
|
||||||
|
"network_count": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import fs from 'node:fs';
|
|
||||||
import os from 'node:os';
|
|
||||||
import path from 'node:path';
|
|
||||||
import {vi} from 'vitest';
|
|
||||||
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-bake-action-'));
|
|
||||||
|
|
||||||
const githubPayload = {
|
|
||||||
repository: {
|
|
||||||
private: true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const githubEventPath = path.join(tmpDir, 'github-event.json');
|
|
||||||
fs.writeFileSync(githubEventPath, JSON.stringify(githubPayload));
|
|
||||||
|
|
||||||
process.env = Object.assign({}, process.env, {
|
|
||||||
TEMP: tmpDir,
|
|
||||||
GITHUB_REPOSITORY: 'docker/bake-action',
|
|
||||||
GITHUB_REF: 'refs/heads/master',
|
|
||||||
GITHUB_RUN_ID: '123456789',
|
|
||||||
GITHUB_RUN_ATTEMPT: '1',
|
|
||||||
GITHUB_EVENT_PATH: githubEventPath,
|
|
||||||
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
|
||||||
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
|
||||||
});
|
|
||||||
|
|
||||||
vi.mock('@actions/github', () => ({
|
|
||||||
context: {
|
|
||||||
repo: {
|
|
||||||
owner: 'docker',
|
|
||||||
repo: 'bake-action'
|
|
||||||
},
|
|
||||||
ref: 'refs/heads/master',
|
|
||||||
runId: 123456789,
|
|
||||||
payload: githubPayload
|
|
||||||
},
|
|
||||||
getOctokit: vi.fn()
|
|
||||||
}));
|
|
||||||
+13
-15
@@ -10,15 +10,22 @@ 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
|
||||||
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
|
||||||
@@ -44,15 +51,6 @@ 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
|
||||||
source:
|
|
||||||
description: "Context to build from. Can be either local to specify the working directory or a remote bake definition"
|
|
||||||
required: false
|
|
||||||
targets:
|
|
||||||
description: "List of bake targets"
|
|
||||||
required: false
|
|
||||||
vars:
|
|
||||||
description: "Variables to set in the Bake definition as list of key-value pair"
|
|
||||||
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 }}
|
||||||
@@ -63,6 +61,6 @@ outputs:
|
|||||||
description: 'Build result metadata'
|
description: 'Build result metadata'
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node24'
|
using: 'node20'
|
||||||
main: 'dist/index.cjs'
|
main: 'dist/index.js'
|
||||||
post: 'dist/index.cjs'
|
post: 'dist/index.js'
|
||||||
|
|||||||
+10
-19
@@ -1,13 +1,12 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
ARG NODE_VERSION=24
|
ARG NODE_VERSION=20
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine AS base
|
FROM node:${NODE_VERSION}-alpine AS base
|
||||||
RUN apk add --no-cache cpio findutils git rsync
|
RUN apk add --no-cache cpio findutils git
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache <<EOT
|
--mount=type=cache,target=/src/.yarn/cache <<EOT
|
||||||
set -e
|
|
||||||
corepack enable
|
corepack enable
|
||||||
yarn --version
|
yarn --version
|
||||||
yarn config set --home enableTelemetry 0
|
yarn config set --home enableTelemetry 0
|
||||||
@@ -28,34 +27,25 @@ RUN --mount=type=bind,target=.,rw <<EOT
|
|||||||
git add -A
|
git add -A
|
||||||
cp -rf /vendor/* .
|
cp -rf /vendor/* .
|
||||||
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then
|
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then
|
||||||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor"'
|
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'
|
||||||
git status --porcelain -- yarn.lock
|
git status --porcelain -- yarn.lock
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
FROM deps AS build
|
FROM deps AS build
|
||||||
RUN --mount=target=/context \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules <<EOT
|
--mount=type=cache,target=/src/node_modules \
|
||||||
set -e
|
yarn run build && mkdir /out && cp -Rf dist /out/
|
||||||
rsync -a /context/. .
|
|
||||||
rm -rf dist
|
|
||||||
yarn run build
|
|
||||||
mkdir /out
|
|
||||||
cp -r dist /out
|
|
||||||
EOT
|
|
||||||
|
|
||||||
FROM scratch AS build-update
|
FROM scratch AS build-update
|
||||||
COPY --from=build /out /
|
COPY --from=build /out /
|
||||||
|
|
||||||
FROM build AS build-validate
|
FROM build AS build-validate
|
||||||
RUN --mount=target=/context \
|
RUN --mount=type=bind,target=.,rw <<EOT
|
||||||
--mount=target=.,type=tmpfs <<EOT
|
|
||||||
set -e
|
set -e
|
||||||
rsync -a /context/. .
|
|
||||||
git add -A
|
git add -A
|
||||||
rm -rf dist
|
|
||||||
cp -rf /out/* .
|
cp -rf /out/* .
|
||||||
if [ -n "$(git status --porcelain -- dist)" ]; then
|
if [ -n "$(git status --porcelain -- dist)" ]; then
|
||||||
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
|
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
|
||||||
@@ -68,7 +58,8 @@ FROM deps AS format
|
|||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules \
|
--mount=type=cache,target=/src/node_modules \
|
||||||
yarn run format && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
|
yarn run format \
|
||||||
|
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
|
||||||
|
|
||||||
FROM scratch AS format-update
|
FROM scratch AS format-update
|
||||||
COPY --from=format /out /
|
COPY --from=format /out /
|
||||||
@@ -83,7 +74,7 @@ FROM deps AS test
|
|||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules \
|
--mount=type=cache,target=/src/node_modules \
|
||||||
yarn run test --coverage --coverage.reportsDirectory=/tmp/coverage
|
yarn run test --coverage --coverageDirectory=/tmp/coverage
|
||||||
|
|
||||||
FROM scratch AS test-coverage
|
FROM scratch AS test-coverage
|
||||||
COPY --from=test /tmp/coverage /
|
COPY --from=test /tmp/coverage /
|
||||||
|
|||||||
-447
File diff suppressed because one or more lines are too long
-7
File diff suppressed because one or more lines are too long
+103
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+2478
-4296
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
@@ -1,9 +1,3 @@
|
|||||||
target "_common" {
|
|
||||||
args = {
|
|
||||||
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
group "default" {
|
group "default" {
|
||||||
targets = ["build"]
|
targets = ["build"]
|
||||||
}
|
}
|
||||||
@@ -17,49 +11,42 @@ group "validate" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
target "build" {
|
target "build" {
|
||||||
inherits = ["_common"]
|
|
||||||
dockerfile = "dev.Dockerfile"
|
dockerfile = "dev.Dockerfile"
|
||||||
target = "build-update"
|
target = "build-update"
|
||||||
output = ["."]
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "build-validate" {
|
target "build-validate" {
|
||||||
inherits = ["_common"]
|
|
||||||
dockerfile = "dev.Dockerfile"
|
dockerfile = "dev.Dockerfile"
|
||||||
target = "build-validate"
|
target = "build-validate"
|
||||||
output = ["type=cacheonly"]
|
output = ["type=cacheonly"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "format" {
|
target "format" {
|
||||||
inherits = ["_common"]
|
|
||||||
dockerfile = "dev.Dockerfile"
|
dockerfile = "dev.Dockerfile"
|
||||||
target = "format-update"
|
target = "format-update"
|
||||||
output = ["."]
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "lint" {
|
target "lint" {
|
||||||
inherits = ["_common"]
|
|
||||||
dockerfile = "dev.Dockerfile"
|
dockerfile = "dev.Dockerfile"
|
||||||
target = "lint"
|
target = "lint"
|
||||||
output = ["type=cacheonly"]
|
output = ["type=cacheonly"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "vendor" {
|
target "vendor" {
|
||||||
inherits = ["_common"]
|
|
||||||
dockerfile = "dev.Dockerfile"
|
dockerfile = "dev.Dockerfile"
|
||||||
target = "vendor-update"
|
target = "vendor-update"
|
||||||
output = ["."]
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "vendor-validate" {
|
target "vendor-validate" {
|
||||||
inherits = ["_common"]
|
|
||||||
dockerfile = "dev.Dockerfile"
|
dockerfile = "dev.Dockerfile"
|
||||||
target = "vendor-validate"
|
target = "vendor-validate"
|
||||||
output = ["type=cacheonly"]
|
output = ["type=cacheonly"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "test" {
|
target "test" {
|
||||||
inherits = ["_common"]
|
|
||||||
dockerfile = "dev.Dockerfile"
|
dockerfile = "dev.Dockerfile"
|
||||||
target = "test-coverage"
|
target = "test-coverage"
|
||||||
output = ["./coverage"]
|
output = ["./coverage"]
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
import {defineConfig} from 'eslint/config';
|
|
||||||
import js from '@eslint/js';
|
|
||||||
import tseslint from '@typescript-eslint/eslint-plugin';
|
|
||||||
import vitest from '@vitest/eslint-plugin';
|
|
||||||
import globals from 'globals';
|
|
||||||
import eslintConfigPrettier from 'eslint-config-prettier/flat';
|
|
||||||
import eslintPluginPrettier from 'eslint-plugin-prettier';
|
|
||||||
|
|
||||||
export default defineConfig([
|
|
||||||
{
|
|
||||||
ignores: ['.yarn/**/*', 'coverage/**/*', 'dist/**/*']
|
|
||||||
},
|
|
||||||
js.configs.recommended,
|
|
||||||
...tseslint.configs['flat/recommended'],
|
|
||||||
eslintConfigPrettier,
|
|
||||||
{
|
|
||||||
languageOptions: {
|
|
||||||
globals: {
|
|
||||||
...globals.node
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ['__tests__/**'],
|
|
||||||
...vitest.configs.recommended,
|
|
||||||
languageOptions: {
|
|
||||||
globals: {
|
|
||||||
...globals.node,
|
|
||||||
...vitest.environments.env.globals
|
|
||||||
}
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
...vitest.configs.recommended.rules,
|
|
||||||
'vitest/no-conditional-expect': 'error',
|
|
||||||
'vitest/no-disabled-tests': 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
plugins: {
|
|
||||||
prettier: eslintPluginPrettier
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
'prettier/prettier': 'error',
|
|
||||||
'@typescript-eslint/no-require-imports': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
allowAsImport: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import os from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-bake-action-'));
|
||||||
|
|
||||||
|
process.env = Object.assign({}, process.env, {
|
||||||
|
TEMP: tmpDir,
|
||||||
|
GITHUB_REPOSITORY: 'docker/bake-action',
|
||||||
|
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
||||||
|
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
||||||
|
}) as {
|
||||||
|
[key: string]: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
clearMocks: true,
|
||||||
|
testEnvironment: 'node',
|
||||||
|
moduleFileExtensions: ['js', 'ts'],
|
||||||
|
testMatch: ['**/*.test.ts'],
|
||||||
|
transform: {
|
||||||
|
'^.+\\.ts$': 'ts-jest'
|
||||||
|
},
|
||||||
|
moduleNameMapper: {
|
||||||
|
'^csv-parse/sync': '<rootDir>/node_modules/csv-parse/dist/cjs/sync.cjs'
|
||||||
|
},
|
||||||
|
collectCoverageFrom: ['src/**/{!(main.ts),}.ts'],
|
||||||
|
coveragePathIgnorePatterns: ['lib/', 'node_modules/', '__mocks__/', '__tests__/'],
|
||||||
|
verbose: true
|
||||||
|
};
|
||||||
+25
-25
@@ -1,14 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "docker-buildx-bake",
|
"name": "docker-buildx-bake",
|
||||||
"description": "GitHub Action to use Docker Buildx Bake as a high-level build command",
|
"description": "GitHub Action to use Docker Buildx Bake as a high-level build command",
|
||||||
"type": "module",
|
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "esbuild src/main.ts --bundle --platform=node --target=node24 --format=cjs --outfile=dist/index.cjs --sourcemap --minify && yarn run license",
|
"build": "ncc build --source-map --minify --license licenses.txt",
|
||||||
"lint": "eslint --max-warnings=0 .",
|
"lint": "yarn run prettier && yarn run eslint",
|
||||||
"format": "eslint --fix .",
|
"format": "yarn run prettier:fix && yarn run eslint:fix",
|
||||||
"test": "vitest run",
|
"eslint": "eslint --max-warnings=0 .",
|
||||||
"license": "generate-license-file --input package.json --output dist/licenses.txt --overwrite --ci --no-spinner --eol lf"
|
"eslint:fix": "eslint --fix .",
|
||||||
|
"prettier": "prettier --check \"./**/*.ts\"",
|
||||||
|
"prettier:fix": "prettier --write \"./**/*.ts\"",
|
||||||
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -22,27 +24,25 @@
|
|||||||
],
|
],
|
||||||
"author": "Docker Inc.",
|
"author": "Docker Inc.",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"packageManager": "yarn@4.9.2",
|
"packageManager": "yarn@3.6.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^3.0.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@docker/actions-toolkit": "^0.90.0",
|
"@docker/actions-toolkit": "^0.53.0",
|
||||||
"handlebars": "^4.7.9"
|
"handlebars": "^4.7.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.39.3",
|
"@types/node": "^20.12.12",
|
||||||
"@types/node": "^24.11.0",
|
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
"@typescript-eslint/parser": "^7.9.0",
|
||||||
"@typescript-eslint/parser": "^8.56.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"@vitest/coverage-v8": "^4.0.18",
|
"eslint": "^8.57.0",
|
||||||
"@vitest/eslint-plugin": "^1.6.9",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"esbuild": "^0.28.0",
|
"eslint-plugin-jest": "^28.5.0",
|
||||||
"eslint": "^9.39.3",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"jest": "^29.7.0",
|
||||||
"eslint-plugin-prettier": "^5.5.5",
|
"prettier": "^3.2.5",
|
||||||
"generate-license-file": "^4.1.1",
|
"ts-jest": "^29.1.2",
|
||||||
"globals": "^17.3.0",
|
"ts-node": "^10.9.2",
|
||||||
"prettier": "^3.8.1",
|
"typescript": "^5.4.5"
|
||||||
"typescript": "^5.9.3",
|
|
||||||
"vitest": "^4.0.18"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+53
-78
@@ -1,25 +1,21 @@
|
|||||||
import * as fs from 'fs';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as handlebars from 'handlebars';
|
import * as handlebars from 'handlebars';
|
||||||
|
|
||||||
import {Bake} from '@docker/actions-toolkit/lib/buildx/bake.js';
|
import {Bake} from '@docker/actions-toolkit/lib/buildx/bake';
|
||||||
import {Build} from '@docker/actions-toolkit/lib/buildx/build.js';
|
import {Build} from '@docker/actions-toolkit/lib/buildx/build';
|
||||||
import {GitHub} from '@docker/actions-toolkit/lib/github/github.js';
|
import {Context} from '@docker/actions-toolkit/lib/context';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit.js';
|
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
||||||
import {Util} from '@docker/actions-toolkit/lib/util.js';
|
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.js';
|
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
||||||
|
|
||||||
export interface BakeContext {
|
|
||||||
remoteRef?: string;
|
|
||||||
workdir?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
builder: string;
|
|
||||||
allow: string[];
|
allow: string[];
|
||||||
call: string;
|
builder: string;
|
||||||
files: string[];
|
files: string[];
|
||||||
|
workdir: string;
|
||||||
|
targets: string[];
|
||||||
'no-cache': boolean;
|
'no-cache': boolean;
|
||||||
pull: boolean;
|
pull: boolean;
|
||||||
load: boolean;
|
load: boolean;
|
||||||
@@ -27,18 +23,17 @@ export interface Inputs {
|
|||||||
push: boolean;
|
push: boolean;
|
||||||
sbom: string;
|
sbom: string;
|
||||||
set: string[];
|
set: string[];
|
||||||
source: BakeContext;
|
source: string;
|
||||||
targets: string[];
|
|
||||||
vars: 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'),
|
|
||||||
allow: Util.getInputList('allow'),
|
allow: Util.getInputList('allow'),
|
||||||
call: core.getInput('call'),
|
builder: core.getInput('builder'),
|
||||||
files: Util.getInputList('files'),
|
files: Util.getInputList('files'),
|
||||||
|
workdir: core.getInput('workdir') || '.',
|
||||||
|
targets: Util.getInputList('targets'),
|
||||||
'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'),
|
||||||
@@ -46,13 +41,33 @@ 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: await getBakeContext(core.getInput('source')),
|
source: getSourceInput('source'),
|
||||||
targets: Util.getInputList('targets'),
|
|
||||||
vars: Util.getInputList('vars', {ignoreComma: true, quote: false}),
|
|
||||||
'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 [
|
||||||
@@ -64,61 +79,41 @@ export async function getArgs(inputs: Inputs, definition: BakeDefinition, toolki
|
|||||||
|
|
||||||
async function getBakeArgs(inputs: Inputs, definition: BakeDefinition, toolkit: Toolkit): Promise<Array<string>> {
|
async function getBakeArgs(inputs: Inputs, definition: BakeDefinition, toolkit: Toolkit): Promise<Array<string>> {
|
||||||
const args: Array<string> = ['bake'];
|
const args: Array<string> = ['bake'];
|
||||||
if (inputs.source.remoteRef) {
|
if (inputs.source) {
|
||||||
args.push(inputs.source.remoteRef);
|
args.push(inputs.source);
|
||||||
}
|
}
|
||||||
if (await toolkit.buildx.versionSatisfies('>=0.17.0')) {
|
if (await toolkit.buildx.versionSatisfies('>=0.17.0')) {
|
||||||
if (await toolkit.buildx.versionSatisfies('>=0.18.0')) {
|
if (await toolkit.buildx.versionSatisfies('>=0.18.0')) {
|
||||||
// allow filesystem entitlements by default
|
// allow filesystem entitlements by default
|
||||||
inputs.allow.push('fs=*');
|
inputs.allow.push('fs=*');
|
||||||
}
|
}
|
||||||
await Util.asyncForEach(inputs.allow, async (allow: string) => {
|
await Util.asyncForEach(inputs.allow, async allow => {
|
||||||
args.push('--allow', allow);
|
args.push('--allow', allow);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (inputs.call) {
|
await Util.asyncForEach(inputs.files, async file => {
|
||||||
if (!(await toolkit.buildx.versionSatisfies('>=0.16.0'))) {
|
|
||||||
throw new Error(`Buildx >= 0.16.0 is required to use the call input.`);
|
|
||||||
}
|
|
||||||
args.push('--call', inputs.call);
|
|
||||||
}
|
|
||||||
await Util.asyncForEach(inputs.files, async (file: string) => {
|
|
||||||
args.push('--file', file);
|
args.push('--file', file);
|
||||||
});
|
});
|
||||||
await Util.asyncForEach(inputs.set, async (s: string) => {
|
await Util.asyncForEach(inputs.set, async set => {
|
||||||
args.push('--set', s);
|
args.push('--set', set);
|
||||||
});
|
});
|
||||||
if (inputs.vars.length > 0) {
|
|
||||||
if (!(await toolkit.buildx.versionSatisfies('>=0.31.0'))) {
|
|
||||||
throw new Error(`Buildx >= 0.31.0 is required to use the vars input.`);
|
|
||||||
}
|
|
||||||
await Util.asyncForEach(inputs.vars, async (v: string) => {
|
|
||||||
args.push('--var', v);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (await toolkit.buildx.versionSatisfies('>=0.6.0')) {
|
if (await toolkit.buildx.versionSatisfies('>=0.6.0')) {
|
||||||
args.push('--metadata-file', toolkit.buildxBake.getMetadataFilePath());
|
args.push('--metadata-file', toolkit.buildxBake.getMetadataFilePath());
|
||||||
}
|
}
|
||||||
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 (!noDefaultAttestations() && (await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !Bake.hasDockerExporter(definition, inputs.load)) {
|
} else if ((await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !Bake.hasDockerExporter(definition, inputs.load)) {
|
||||||
// check if provenance attestation is already specified in the bake
|
// if provenance not specified and BuildKit version compatible for
|
||||||
// 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.
|
||||||
for (const targetName in definition.target) {
|
|
||||||
const target = definition.target[targetName];
|
|
||||||
if (!Array.isArray(target.attest) || !target.attest.some(attest => attest?.type === 'provenance')) {
|
|
||||||
if (GitHub.context.payload.repository?.private ?? false) {
|
if (GitHub.context.payload.repository?.private ?? false) {
|
||||||
// if this is a private repository, we set the default provenance
|
// if this is a private repository, we set the default provenance
|
||||||
// attributes being set in buildx: https://github.com/docker/buildx/blob/fb27e3f919dcbf614d7126b10c2bc2d0b1927eb6/build/build.go#L603
|
// attributes being set in buildx: https://github.com/docker/buildx/blob/fb27e3f919dcbf614d7126b10c2bc2d0b1927eb6/build/build.go#L603
|
||||||
args.push('--set', `${targetName}.attest=type=provenance,${Build.resolveProvenanceAttrs(`mode=min,inline-only=true`)}`);
|
args.push('--provenance', Build.resolveProvenanceAttrs(`mode=min,inline-only=true`));
|
||||||
} else {
|
} else {
|
||||||
// for a public repository, we set max provenance mode.
|
// for a public repository, we set max provenance mode.
|
||||||
args.push('--set', `${targetName}.attest=type=provenance,${Build.resolveProvenanceAttrs(`mode=max`)}`);
|
args.push('--provenance', Build.resolveProvenanceAttrs(`mode=max`));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inputs.sbom) {
|
if (inputs.sbom) {
|
||||||
@@ -148,32 +143,12 @@ async function getCommonArgs(inputs: Inputs): Promise<Array<string>> {
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBakeContext(sourceInput: string): Promise<BakeContext> {
|
function getSourceInput(name: string): string {
|
||||||
const defaultContext = await new Build().gitContext();
|
let source = handlebars.compile(core.getInput(name))({
|
||||||
let bakeContext = handlebars.compile(sourceInput)({
|
defaultContext: Context.gitContext()
|
||||||
defaultContext: defaultContext
|
|
||||||
});
|
});
|
||||||
if (!bakeContext) {
|
if (source === '.') {
|
||||||
bakeContext = defaultContext;
|
source = '';
|
||||||
}
|
}
|
||||||
if (Util.isValidRef(bakeContext)) {
|
return source;
|
||||||
return {
|
|
||||||
remoteRef: bakeContext
|
|
||||||
};
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
fs.statSync(sourceInput).isDirectory();
|
|
||||||
} catch {
|
|
||||||
throw new Error(`Invalid source: ${sourceInput} does not exist or is not a directory.`);
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
workdir: bakeContext
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function noDefaultAttestations(): boolean {
|
|
||||||
if (process.env.BUILDX_NO_DEFAULT_ATTESTATIONS) {
|
|
||||||
return Util.parseBool(process.env.BUILDX_NO_DEFAULT_ATTESTATIONS);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-55
@@ -3,24 +3,22 @@ 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.js';
|
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
|
||||||
import {History as BuildxHistory} from '@docker/actions-toolkit/lib/buildx/history.js';
|
import {History as BuildxHistory} from '@docker/actions-toolkit/lib/buildx/history';
|
||||||
import {Context} from '@docker/actions-toolkit/lib/context.js';
|
import {Context} from '@docker/actions-toolkit/lib/context';
|
||||||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';
|
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||||
import {Exec} from '@docker/actions-toolkit/lib/exec.js';
|
import {Exec} from '@docker/actions-toolkit/lib/exec';
|
||||||
import {GitHub} from '@docker/actions-toolkit/lib/github/github.js';
|
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
||||||
import {GitHubArtifact} from '@docker/actions-toolkit/lib/github/artifact.js';
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||||
import {GitHubSummary} from '@docker/actions-toolkit/lib/github/summary.js';
|
import {Util} from '@docker/actions-toolkit/lib/util';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit.js';
|
|
||||||
import {Util} from '@docker/actions-toolkit/lib/util.js';
|
|
||||||
|
|
||||||
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake.js';
|
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
||||||
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder.js';
|
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder';
|
||||||
import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker.js';
|
import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker';
|
||||||
import {UploadResponse as UploadArtifactResponse} from '@docker/actions-toolkit/lib/types/github/artifact.js';
|
import {UploadArtifactResponse} from '@docker/actions-toolkit/lib/types/github';
|
||||||
|
|
||||||
import * as context from './context.js';
|
import * as context from './context';
|
||||||
import * as stateHelper from './state-helper.js';
|
import * as stateHelper from './state-helper';
|
||||||
|
|
||||||
actionsToolkit.run(
|
actionsToolkit.run(
|
||||||
// main
|
// main
|
||||||
@@ -28,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'];
|
||||||
@@ -90,8 +88,6 @@ 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));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -107,13 +103,12 @@ actionsToolkit.run(
|
|||||||
provenance: inputs.provenance,
|
provenance: inputs.provenance,
|
||||||
push: inputs.push,
|
push: inputs.push,
|
||||||
sbom: inputs.sbom,
|
sbom: inputs.sbom,
|
||||||
source: inputs.source.remoteRef,
|
source: inputs.source,
|
||||||
targets: inputs.targets,
|
targets: inputs.targets,
|
||||||
vars: inputs.vars,
|
|
||||||
githubToken: gitAuthToken
|
githubToken: gitAuthToken
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cwd: inputs.source.workdir
|
cwd: inputs.workdir
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -133,7 +128,7 @@ actionsToolkit.run(
|
|||||||
|
|
||||||
await core.group(`Bake definition`, async () => {
|
await core.group(`Bake definition`, async () => {
|
||||||
await Exec.getExecOutput(buildCmd.command, [...buildCmd.args, '--print'], {
|
await Exec.getExecOutput(buildCmd.command, [...buildCmd.args, '--print'], {
|
||||||
cwd: inputs.source.workdir,
|
cwd: inputs.workdir,
|
||||||
env: buildEnv,
|
env: buildEnv,
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
@@ -145,31 +140,13 @@ actionsToolkit.run(
|
|||||||
|
|
||||||
let err: Error | undefined;
|
let err: Error | undefined;
|
||||||
await Exec.getExecOutput(buildCmd.command, buildCmd.args, {
|
await Exec.getExecOutput(buildCmd.command, buildCmd.args, {
|
||||||
cwd: inputs.source.workdir,
|
cwd: inputs.workdir,
|
||||||
env: buildEnv,
|
env: buildEnv,
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
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'}`);
|
err = Error(`buildx bake failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const metadata = toolkit.buildxBake.resolveMetadata();
|
const metadata = toolkit.buildxBake.resolveMetadata();
|
||||||
@@ -212,12 +189,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.23.0'))) {
|
} else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) {
|
||||||
core.info('Build summary requires Buildx >= 0.23.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 {
|
||||||
@@ -249,19 +226,18 @@ actionsToolkit.run(
|
|||||||
|
|
||||||
let uploadRes: UploadArtifactResponse | undefined;
|
let uploadRes: UploadArtifactResponse | undefined;
|
||||||
if (recordUploadEnabled) {
|
if (recordUploadEnabled) {
|
||||||
uploadRes = await GitHubArtifact.upload({
|
uploadRes = await GitHub.uploadArtifact({
|
||||||
filename: exportRes.dockerbuildFilename,
|
filename: exportRes.dockerbuildFilename,
|
||||||
|
mimeType: 'application/gzip',
|
||||||
retentionDays: recordRetentionDays
|
retentionDays: recordRetentionDays
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await GitHubSummary.writeBuildSummary({
|
await GitHub.writeBuildSummary({
|
||||||
exportRes: exportRes,
|
exportRes: exportRes,
|
||||||
uploadRes: uploadRes,
|
uploadRes: uploadRes,
|
||||||
inputs: stateHelper.summaryInputs,
|
inputs: stateHelper.inputs,
|
||||||
bakeDefinition: stateHelper.bakeDefinition,
|
bakeDefinition: stateHelper.bakeDefinition
|
||||||
driver: stateHelper.builderDriver,
|
|
||||||
endpoint: stateHelper.builderEndpoint
|
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
core.warning(e.message);
|
core.warning(e.message);
|
||||||
@@ -309,7 +285,10 @@ function buildChecksAnnotationsEnabled(): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildSummaryEnabled(): boolean {
|
function buildSummaryEnabled(): boolean {
|
||||||
if (process.env.DOCKER_BUILD_SUMMARY) {
|
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 Util.parseBool(process.env.DOCKER_BUILD_SUMMARY);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -323,7 +302,13 @@ function buildRecordUploadEnabled(): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildRecordRetentionDays(): number | undefined {
|
function buildRecordRetentionDays(): number | undefined {
|
||||||
const val = process.env.DOCKER_BUILD_RECORD_RETENTION_DAYS;
|
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) {
|
if (val) {
|
||||||
const res = parseInt(val);
|
const res = parseInt(val);
|
||||||
if (isNaN(res)) {
|
if (isNaN(res)) {
|
||||||
|
|||||||
+5
-35
@@ -1,16 +1,12 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake.js';
|
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
||||||
|
|
||||||
import {Inputs} from './context.js';
|
import {Inputs, sanitizeInputs} 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'];
|
||||||
|
|
||||||
@@ -18,12 +14,8 @@ export function setTmpDir(tmpDir: string) {
|
|||||||
core.saveState('tmpDir', tmpDir);
|
core.saveState('tmpDir', tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setBuilderDriver(builderDriver: string) {
|
export function setInputs(inputs: Inputs) {
|
||||||
core.saveState('builderDriver', builderDriver);
|
core.saveState('inputs', JSON.stringify(sanitizeInputs(inputs)));
|
||||||
}
|
|
||||||
|
|
||||||
export function setBuilderEndpoint(builderEndpoint: string) {
|
|
||||||
core.saveState('builderEndpoint', builderEndpoint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setBakeDefinition(bakeDefinition: BakeDefinition) {
|
export function setBakeDefinition(bakeDefinition: BakeDefinition) {
|
||||||
@@ -37,25 +29,3 @@ 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 = {};
|
|
||||||
if (inputs.source.remoteRef || inputs.source.workdir) {
|
|
||||||
res['source'] = inputs.source.remoteRef || inputs.source.workdir;
|
|
||||||
}
|
|
||||||
for (const key of Object.keys(inputs)) {
|
|
||||||
if (key === 'source' || 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,84 @@
|
|||||||
|
## 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@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@v5
|
||||||
|
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 targest |
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
|
||||||
|
name: 'List Bake targets'
|
||||||
|
description: 'Generate a list of Bake targets to help distributing builds in your workflow'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
workdir:
|
||||||
|
description: Working directory
|
||||||
|
default: '.'
|
||||||
|
required: false
|
||||||
|
files:
|
||||||
|
description: Comma separated list of Bake files
|
||||||
|
required: false
|
||||||
|
target:
|
||||||
|
description: Bake target
|
||||||
|
required: false
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
targets:
|
||||||
|
description: List of targets
|
||||||
|
value: ${{ steps.generate.outputs.targets }}
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Generate
|
||||||
|
id: generate
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
let def;
|
||||||
|
const files = `${{ inputs.files }}` ? `${{ inputs.files }}`.split(/[\r?\n,]+/).filter(Boolean) : [];
|
||||||
|
const target = `${{ inputs.target }}`;
|
||||||
|
|
||||||
|
await core.group(`Validating 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: `${{ inputs.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(`Set output`, async () => {
|
||||||
|
const targets = Object.keys(def.target);
|
||||||
|
core.info(`targets: ${JSON.stringify(targets)}`);
|
||||||
|
core.setOutput('targets', JSON.stringify(targets));
|
||||||
|
});
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
## 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@v6
|
|
||||||
-
|
|
||||||
name: Generate matrix
|
|
||||||
id: generate
|
|
||||||
uses: docker/bake-action/subaction/matrix@v7
|
|
||||||
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@v7
|
|
||||||
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@v6
|
|
||||||
-
|
|
||||||
name: Generate matrix
|
|
||||||
id: generate
|
|
||||||
uses: docker/bake-action/subaction/matrix@v7
|
|
||||||
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@v7
|
|
||||||
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 |
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
# 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@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
||||||
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));
|
|
||||||
});
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# 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"
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
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"]
|
|
||||||
}
|
|
||||||
+4
-9
@@ -6,26 +6,21 @@ group "release" {
|
|||||||
targets = ["db", "app-plus"]
|
targets = ["db", "app-plus"]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Special target: https://github.com/docker/metadata-action#bake-definition
|
|
||||||
target "docker-metadata-action" {
|
|
||||||
tags = [
|
|
||||||
"localhost:5000/name/app:latest",
|
|
||||||
"localhost:5000/name/app:1.0.0"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
target "db" {
|
target "db" {
|
||||||
context = "./test"
|
context = "./test"
|
||||||
tags = ["docker.io/tonistiigi/db"]
|
tags = ["docker.io/tonistiigi/db"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "app" {
|
target "app" {
|
||||||
inherits = ["docker-metadata-action"]
|
|
||||||
context = "./test"
|
context = "./test"
|
||||||
dockerfile = "Dockerfile"
|
dockerfile = "Dockerfile"
|
||||||
args = {
|
args = {
|
||||||
name = "foo"
|
name = "foo"
|
||||||
}
|
}
|
||||||
|
tags = [
|
||||||
|
"localhost:5000/name/app:latest",
|
||||||
|
"localhost:5000/name/app:1.0.0"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "cross" {
|
target "cross" {
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
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"]
|
|
||||||
}
|
|
||||||
+9
-4
@@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "nodenext",
|
|
||||||
"moduleResolution": "nodenext",
|
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
"target": "es6",
|
||||||
|
"module": "commonjs",
|
||||||
|
"strict": true,
|
||||||
"newLine": "lf",
|
"newLine": "lf",
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
@@ -11,7 +12,11 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"useUnknownInCatchVariables": false,
|
"useUnknownInCatchVariables": false,
|
||||||
},
|
},
|
||||||
"include": [
|
"exclude": [
|
||||||
"src/**/*.ts"
|
"./__mocks__/**/*",
|
||||||
|
"./__tests__/**/*",
|
||||||
|
"./lib/**/*",
|
||||||
|
"node_modules",
|
||||||
|
"jest.config.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
import {defineConfig} from 'vitest/config';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
test: {
|
|
||||||
clearMocks: true,
|
|
||||||
environment: 'node',
|
|
||||||
setupFiles: ['./__tests__/setup.unit.ts'],
|
|
||||||
include: ['**/*.test.ts'],
|
|
||||||
coverage: {
|
|
||||||
provider: 'v8',
|
|
||||||
reporter: ['clover'],
|
|
||||||
include: ['src/**/*.ts'],
|
|
||||||
exclude: ['src/**/main.ts']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user