Compare commits

..

No commits in common. "master" and "v6.9.0" have entirely different histories.

27 changed files with 1959 additions and 2550 deletions

3
.eslintignore Normal file
View File

@ -0,0 +1,3 @@
/dist/**
/coverage/**
/node_modules/**

24
.eslintrc.json Normal file
View File

@ -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": 2023,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"jest",
"prettier"
]
}

View File

@ -76,7 +76,6 @@ until $(curl --output /dev/null --silent --head --fail "http://$NEXUS_HOST:$NEXU
printf '.' printf '.'
sleep 5 sleep 5
done done
echo "ready!"
echo "::endgroup::" echo "::endgroup::"
echo "::group::Change user's password" echo "::group::Change user's password"

View File

@ -27,9 +27,9 @@ on:
type: string type: string
env: env:
HARBOR_VERSION: v2.13.2 HARBOR_VERSION: v2.7.0
NEXUS_VERSION: 3.47.1 NEXUS_VERSION: 3.47.1
DISTRIBUTION_VERSION: 3.0.0 DISTRIBUTION_VERSION: 2.8.1
jobs: jobs:
run: run:
@ -38,9 +38,6 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
-
buildx_version: edge
buildkit_image: moby/buildkit:latest
- -
buildx_version: latest buildx_version: latest
buildkit_image: moby/buildkit:buildx-stable-1 buildkit_image: moby/buildkit:buildx-stable-1
@ -50,7 +47,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up env name: Set up env
if: inputs.type == 'local' if: inputs.type == 'local'
@ -68,11 +65,10 @@ jobs:
if: inputs.type == 'local' if: inputs.type == 'local'
run: | run: |
if [ ! -e /etc/docker/daemon.json ]; then if [ ! -e /etc/docker/daemon.json ]; then
echo '{}' | sudo tee /etc/docker/daemon.json >/dev/null echo '{}' | tee /etc/docker/daemon.json >/dev/null
fi fi
DOCKERD_CONFIG=$(jq '.+{"insecure-registries":["http://${{ env.REGISTRY_FQDN }}"]}' /etc/docker/daemon.json) DOCKERD_CONFIG=$(jq '.+{"insecure-registries":["http://${{ env.REGISTRY_FQDN }}"]}' /etc/docker/daemon.json)
sudo tee /etc/docker/daemon.json <<<"$DOCKERD_CONFIG" >/dev/null sudo tee /etc/docker/daemon.json <<<"$DOCKERD_CONFIG" >/dev/null
cat /etc/docker/daemon.json
sudo service docker restart sudo service docker restart
- -
name: Install ${{ inputs.name }} name: Install ${{ inputs.name }}

View File

@ -24,8 +24,8 @@ on:
pull_request: pull_request:
env: env:
BUILDX_VERSION: edge BUILDX_VERSION: latest
BUILDKIT_IMAGE: moby/buildkit:latest BUILDKIT_IMAGE: moby/buildkit:buildx-stable-1
jobs: jobs:
minimal: minimal:
@ -33,7 +33,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
with: with:
path: action path: action
- -
@ -59,7 +59,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
with: with:
path: action path: action
- -
@ -108,7 +108,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
with: with:
path: action path: action
- -
@ -167,7 +167,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -216,7 +216,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
@ -272,7 +272,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Stop docker name: Stop docker
run: | run: |
@ -288,6 +288,7 @@ jobs:
- -
name: Check name: Check
run: | run: |
echo "${{ toJson(steps.docker_build) }}"
if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then
echo "::error::Should have failed" echo "::error::Should have failed"
exit 1 exit 1
@ -298,7 +299,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -323,6 +324,7 @@ jobs:
- -
name: Check name: Check
run: | run: |
echo "${{ toJson(steps.docker_build) }}"
if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then
echo "::error::Should have failed" echo "::error::Should have failed"
exit 1 exit 1
@ -338,7 +340,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Build name: Build
id: docker_build id: docker_build
@ -354,7 +356,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Build name: Build
uses: ./ uses: ./
@ -373,7 +375,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -396,7 +398,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker buildx name: Set up Docker buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -421,7 +423,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -445,7 +447,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -467,7 +469,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -492,7 +494,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -515,7 +517,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -540,7 +542,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -565,8 +567,6 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- buildx: edge
buildkit: moby/buildkit:latest
- buildx: latest - buildx: latest
buildkit: moby/buildkit:buildx-stable-1 buildkit: moby/buildkit:buildx-stable-1
- buildx: latest - buildx: latest
@ -576,7 +576,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -619,7 +619,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -671,7 +671,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -723,7 +723,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -792,7 +792,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -862,7 +862,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -911,7 +911,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -952,7 +952,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -967,7 +967,7 @@ jobs:
buildkitd-flags: --debug buildkitd-flags: --debug
- -
name: Cache Build name: Cache Build
uses: actions/cache@v5 uses: actions/cache@v4
with: with:
path: /tmp/.buildx-cache path: /tmp/.buildx-cache
key: ${{ runner.os }}-local-test-${{ github.sha }} key: ${{ runner.os }}-local-test-${{ github.sha }}
@ -1004,7 +1004,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Uninstall docker cli name: Uninstall docker cli
run: | run: |
@ -1033,7 +1033,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -1055,7 +1055,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -1089,7 +1089,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -1120,7 +1120,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set malformed docker config name: Set malformed docker config
run: | run: |
@ -1147,7 +1147,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@v6 uses: actions/checkout@v4
- -
name: Set proxy config name: Set proxy config
run: | run: |
@ -1184,7 +1184,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@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -1215,7 +1215,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Docker meta name: Docker meta
id: meta id: meta
@ -1265,7 +1265,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -1314,7 +1314,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -1350,7 +1350,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
with: with:
path: action path: action
- -
@ -1373,7 +1373,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
with: with:
path: action path: action
- -
@ -1396,7 +1396,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
with: with:
path: action path: action
- -
@ -1417,7 +1417,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
with: with:
path: action path: action
- -
@ -1446,7 +1446,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
with: with:
path: action path: action
- -
@ -1464,48 +1464,18 @@ jobs:
env: env:
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }} DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }}
export-legacy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
legacy:
- false
- true
steps:
-
name: Checkout
uses: actions/checkout@v6
with:
path: action
-
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: ./action
with:
file: ./test/Dockerfile
env:
DOCKER_BUILD_EXPORT_LEGACY: ${{ matrix.legacy }}
checks: checks:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
buildx-version: buildx-version:
- edge
- latest - latest
- v0.14.1 - v0.14.1
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -1525,7 +1495,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -1541,56 +1511,3 @@ jobs:
file: ./test/lint.Dockerfile file: ./test/lint.Dockerfile
env: env:
DOCKER_BUILD_CHECKS_ANNOTATIONS: false DOCKER_BUILD_CHECKS_ANNOTATIONS: false
call-check:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v6
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
driver-opts: |
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
-
name: Build
id: docker_build
continue-on-error: true
uses: ./
with:
context: ./test
file: ./test/lint.Dockerfile
call: check
-
name: Check
run: |
if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then
echo "::error::Should have failed"
exit 1
fi
no-default-attestations:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v6
with:
path: action
-
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: ./action
with:
file: ./test/Dockerfile
env:
BUILDX_NO_DEFAULT_ATTESTATIONS: 1

View File

@ -67,6 +67,13 @@ jobs:
username_secret: GAR_USERNAME username_secret: GAR_USERNAME
password_secret: GAR_JSON_KEY password_secret: GAR_JSON_KEY
type: remote type: remote
-
name: Google Container Registry
registry: gcr.io
slug: gcr.io/sandbox-298914/test-docker-action
username_secret: GCR_USERNAME
password_secret: GCR_JSON_KEY
type: remote
- -
name: Azure Container Registry name: Azure Container Registry
registry: officialgithubactions.azurecr.io registry: officialgithubactions.azurecr.io

View File

@ -1,17 +0,0 @@
name: pr-assign-author
permissions:
contents: read
on:
pull_request_target:
types:
- opened
- reopened
jobs:
run:
uses: crazy-max/.github/.github/workflows/pr-assign-author.yml@1b673f36fad86812f538c1df9794904038a23cbf
permissions:
contents: read
pull-requests: write

View File

@ -1,21 +0,0 @@
name: publish
on:
release:
types:
- published
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
-
name: Checkout
uses: actions/checkout@v6
-
name: Publish
uses: actions/publish-immutable-action@v0.0.4

View File

@ -17,16 +17,15 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v4
- -
name: Test name: Test
uses: docker/bake-action@v6 uses: docker/bake-action@v5
with: with:
source: .
targets: test targets: test
- -
name: Upload coverage name: Upload coverage
uses: codecov/codecov-action@v5 uses: codecov/codecov-action@v4
with: with:
files: ./coverage/clover.xml file: ./coverage/clover.xml
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}

View File

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

View File

@ -60,18 +60,18 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
@ -131,19 +131,19 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v5 uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
@ -162,7 +162,6 @@ jobs:
* [Cache management](https://docs.docker.com/build/ci/github-actions/cache/) * [Cache management](https://docs.docker.com/build/ci/github-actions/cache/)
* [Export to Docker](https://docs.docker.com/build/ci/github-actions/export-docker/) * [Export to Docker](https://docs.docker.com/build/ci/github-actions/export-docker/)
* [Test before push](https://docs.docker.com/build/ci/github-actions/test-before-push/) * [Test before push](https://docs.docker.com/build/ci/github-actions/test-before-push/)
* [Validating build configuration](https://docs.docker.com/build/ci/github-actions/checks/)
* [Local registry](https://docs.docker.com/build/ci/github-actions/local-registry/) * [Local registry](https://docs.docker.com/build/ci/github-actions/local-registry/)
* [Share built image between jobs](https://docs.docker.com/build/ci/github-actions/share-image-jobs/) * [Share built image between jobs](https://docs.docker.com/build/ci/github-actions/share-image-jobs/)
* [Named contexts](https://docs.docker.com/build/ci/github-actions/named-contexts/) * [Named contexts](https://docs.docker.com/build/ci/github-actions/named-contexts/)
@ -186,19 +185,6 @@ additional details about the build, including build stats, logs, outputs, and
more. The build record can be imported to Docker Desktop for inspecting the more. The build record can be imported to Docker Desktop for inspecting the
build in greater detail. 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).
@ -234,7 +220,6 @@ The following inputs can be used as `step.with` keys:
| `build-contexts` | List | List of additional [build contexts](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-context) (e.g., `name=path`) | | `build-contexts` | List | List of additional [build contexts](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-context) (e.g., `name=path`) |
| `cache-from` | List | List of [external cache sources](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-from) (e.g., `type=local,src=path/to/dir`) | | `cache-from` | List | List of [external cache sources](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-from) (e.g., `type=local,src=path/to/dir`) |
| `cache-to` | List | List of [cache export destinations](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-to) (e.g., `type=local,dest=path/to/dir`) | | `cache-to` | List | List of [cache export destinations](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-to) (e.g., `type=local,dest=path/to/dir`) |
| `call` | String | Set [method for evaluating build](https://docs.docker.com/reference/cli/docker/buildx/build/#call) (e.g., `check`) |
| `cgroup-parent` | String | Optional [parent cgroup](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) for the container used in the build | | `cgroup-parent` | String | Optional [parent cgroup](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) for the container used in the build |
| `context` | String | Build's context is the set of files located in the specified [`PATH` or `URL`](https://docs.docker.com/engine/reference/commandline/build/) (default [Git context](#git-context)) | | `context` | String | Build's context is the set of files located in the specified [`PATH` or `URL`](https://docs.docker.com/engine/reference/commandline/build/) (default [Git context](#git-context)) |
| `file` | String | Path to the Dockerfile. (default `{context}/Dockerfile`) | | `file` | String | Path to the Dockerfile. (default `{context}/Dockerfile`) |
@ -277,7 +262,6 @@ The following outputs are available:
| `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation is disabled | | `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation is disabled |
| `DOCKER_BUILD_RECORD_UPLOAD` | Bool | `true` | If `false`, build record upload as [GitHub artifact](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts) is disabled | | `DOCKER_BUILD_RECORD_UPLOAD` | Bool | `true` | If `false`, build record upload as [GitHub artifact](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts) is disabled |
| `DOCKER_BUILD_RECORD_RETENTION_DAYS` | Number | | Duration after which build record artifact will expire in days. Defaults to repository/org [retention settings](https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#artifact-and-log-retention-policy) if unset or `0` | | `DOCKER_BUILD_RECORD_RETENTION_DAYS` | Number | | Duration after which build record artifact will expire in days. Defaults to repository/org [retention settings](https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#artifact-and-log-retention-policy) if unset or `0` |
| `DOCKER_BUILD_EXPORT_LEGACY` | Bool | `false` | If `true`, exports build using legacy export-build tool instead of [`buildx history export` command](https://docs.docker.com/reference/cli/docker/buildx/history/export/) |
## Troubleshooting ## Troubleshooting

View File

@ -4,6 +4,7 @@
* [BuildKit container logs](#buildkit-container-logs) * [BuildKit container logs](#buildkit-container-logs)
* [With containerd](#with-containerd) * [With containerd](#with-containerd)
* [`repository name must be lowercase`](#repository-name-must-be-lowercase) * [`repository name must be lowercase`](#repository-name-must-be-lowercase)
* [Image not loaded](#image-not-loaded)
## Cannot push to a registry ## Cannot push to a registry
@ -135,3 +136,29 @@ Or a dedicated step to sanitize the slug:
push: true push: true
tags: ${{ steps.repo_slug.outputs.result }}:latest tags: ${{ steps.repo_slug.outputs.result }}:latest
``` ```
## Image not loaded
Sometimes when your workflows are heavy consumers of disk storage, it can happen that build-push-action declares that the built image is loaded, but then not found in the following workflow steps.
- You can use the following solution as workaround, to free space on disk before building docker image using the following workflow step
```yaml
# Free disk space
- name: Free Disk space
shell: bash
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
```
- Another workaround can be to call `docker/setup-buildx-action` with docker driver
```yaml
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
```
More details in the [related issue](https://github.com/docker/build-push-action/issues/321)

View File

@ -1,4 +1,4 @@
import {afterEach, beforeEach, describe, expect, jest, test} from '@jest/globals'; import {beforeEach, describe, expect, jest, test} from '@jest/globals';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
@ -68,7 +68,6 @@ jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<Bu
}); });
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_')) {
@ -77,9 +76,6 @@ describe('getArgs', () => {
return object; return object;
}, {}); }, {});
}); });
afterEach(() => {
process.env = originalEnv;
});
// prettier-ignore // prettier-ignore
test.each([ test.each([
@ -97,8 +93,7 @@ describe('getArgs', () => {
'build', 'build',
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'.' '.'
], ]
undefined
], ],
[ [
1, 1,
@ -121,8 +116,7 @@ ccc"`],
'--build-arg', `MULTILINE=aaaa\nbbbb\nccc`, '--build-arg', `MULTILINE=aaaa\nbbbb\nccc`,
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
2, 2,
@ -140,8 +134,7 @@ ccc"`],
'--tag', 'name/app:7.4', '--tag', 'name/app:7.4',
'--tag', 'name/app:latest', '--tag', 'name/app:latest',
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
3, 3,
@ -161,8 +154,7 @@ ccc"`],
'--label', 'org.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit', '--label', 'org.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit',
'--output', 'type=local,dest=./release-out', '--output', 'type=local,dest=./release-out',
'.' '.'
], ]
undefined
], ],
[ [
4, 4,
@ -179,8 +171,7 @@ ccc"`],
'build', 'build',
'--platform', 'linux/amd64,linux/arm64', '--platform', 'linux/amd64,linux/arm64',
'.' '.'
], ]
undefined
], ],
[ [
5, 5,
@ -196,8 +187,7 @@ ccc"`],
'build', 'build',
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'.' '.'
], ]
undefined
], ],
[ [
6, 6,
@ -215,8 +205,7 @@ ccc"`],
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'.' '.'
], ]
undefined
], ],
[ [
7, 7,
@ -234,8 +223,7 @@ ccc"`],
'--output', '.', '--output', '.',
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
8, 8,
@ -261,8 +249,7 @@ ccc"`],
'--builder', 'builder-git-context-2', '--builder', 'builder-git-context-2',
'--push', '--push',
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
9, 9,
@ -299,8 +286,7 @@ ccc"`],
'--builder', 'builder-git-context-2', '--builder', 'builder-git-context-2',
'--push', '--push',
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
10, 10,
@ -337,8 +323,7 @@ ccc`],
'--builder', 'builder-git-context-2', '--builder', 'builder-git-context-2',
'--push', '--push',
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
11, 11,
@ -364,8 +349,7 @@ ccc`],
'--network', 'host', '--network', 'host',
'--push', '--push',
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
12, 12,
@ -385,8 +369,7 @@ ccc`],
'--label', 'org.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"', '--label', 'org.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"',
'--output', 'type=local,dest=./release-out', '--output', 'type=local,dest=./release-out',
'.' '.'
], ]
undefined
], ],
[ [
13, 13,
@ -412,8 +395,7 @@ ccc`],
'--network', 'host', '--network', 'host',
'--push', '--push',
'.' '.'
], ]
undefined
], ],
[ [
14, 14,
@ -443,8 +425,7 @@ nproc=3`],
'--ulimit', 'nproc=3', '--ulimit', 'nproc=3',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
15, 15,
@ -461,8 +442,7 @@ nproc=3`],
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'https://github.com/docker/build-push-action.git#refs/heads/master:docker' 'https://github.com/docker/build-push-action.git#refs/heads/master:docker'
], ]
undefined
], ],
[ [
16, 16,
@ -481,8 +461,7 @@ nproc=3`],
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'https://github.com/docker/build-push-action.git#refs/heads/master:subdir' 'https://github.com/docker/build-push-action.git#refs/heads/master:subdir'
], ]
undefined
], ],
[ [
17, 17,
@ -500,8 +479,7 @@ nproc=3`],
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
18, 18,
@ -519,8 +497,7 @@ nproc=3`],
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
19, 19,
@ -539,8 +516,7 @@ nproc=3`],
'--attest', `type=provenance,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
20, 20,
@ -559,8 +535,7 @@ nproc=3`],
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
21, 21,
@ -579,8 +554,7 @@ nproc=3`],
'--attest', 'type=provenance,disabled=true', '--attest', 'type=provenance,disabled=true',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
22, 22,
@ -599,8 +573,7 @@ nproc=3`],
'--attest', 'type=provenance,builder-id=foo', '--attest', 'type=provenance,builder-id=foo',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
23, 23,
@ -619,8 +592,7 @@ nproc=3`],
"--output", 'type=docker', "--output", 'type=docker',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
24, 24,
@ -638,8 +610,7 @@ nproc=3`],
'--load', '--load',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
25, 25,
@ -659,8 +630,7 @@ nproc=3`],
'--load', '--load',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
26, 26,
@ -682,8 +652,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--load', '--load',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
27, 27,
@ -704,8 +673,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--load', '--load',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
28, 28,
@ -725,8 +693,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
29, 29,
@ -750,8 +717,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
30, 30,
@ -771,8 +737,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
31, 31,
@ -793,8 +758,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=sbom,disabled=false`, '--attest', `type=sbom,disabled=false`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
32, 32,
@ -814,8 +778,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
33, 33,
@ -834,37 +797,11 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=provenance,mode=min,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=min,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
],
[
34,
'0.13.1',
new Map<string, string>([
['context', '.'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]),
[
'build',
'--iidfile', imageIDFilePath,
'--metadata-file', metadataJson,
'.'
],
new Map<string, string>([
['BUILDX_NO_DEFAULT_ATTESTATIONS', '1']
])
], ],
])( ])(
'[%d] given %p with %p as inputs, returns %p', '[%d] given %p with %p as inputs, returns %p',
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>, 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);
}); });

View File

@ -34,9 +34,6 @@ inputs:
cache-to: cache-to:
description: "List of cache export destinations for buildx (e.g., user/app:cache, type=local,dest=path/to/dir)" description: "List of cache export destinations for buildx (e.g., user/app:cache, type=local,dest=path/to/dir)"
required: false required: false
call:
description: "Set method for evaluating build (e.g., check)"
required: false
cgroup-parent: cgroup-parent:
description: "Optional parent cgroup for the container used in the build" description: "Optional parent cgroup for the container used in the build"
required: false required: false

42
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

6
dist/licenses.txt generated vendored
View File

@ -2358,6 +2358,9 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
dot-object
MIT
encoding encoding
MIT MIT
Copyright (c) 2012-2014 Andris Reinman Copyright (c) 2012-2014 Andris Reinman
@ -3688,6 +3691,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
twirp-ts
MIT
undici undici
MIT MIT
MIT License MIT License

2
dist/sourcemap-register.js generated vendored

File diff suppressed because one or more lines are too long

View File

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

View File

@ -1,58 +0,0 @@
/* eslint-disable @typescript-eslint/no-require-imports */
const {defineConfig, globalIgnores} = require('eslint/config');
const {fixupConfigRules, fixupPluginRules} = require('@eslint/compat');
const typescriptEslint = require('@typescript-eslint/eslint-plugin');
const jestPlugin = require('eslint-plugin-jest');
const prettier = require('eslint-plugin-prettier');
const globals = require('globals');
const tsParser = require('@typescript-eslint/parser');
const js = require('@eslint/js');
const {FlatCompat} = require('@eslint/eslintrc');
// __dirname and __filename exist natively in CommonJS
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
module.exports = defineConfig([
globalIgnores(['dist/**/*', 'coverage/**/*', 'node_modules/**/*']),
{
// prettier-ignore
extends: fixupConfigRules(
compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:jest/recommended',
'plugin:prettier/recommended'
)
),
plugins: {
'@typescript-eslint': fixupPluginRules(typescriptEslint),
jest: fixupPluginRules(jestPlugin),
prettier: fixupPluginRules(prettier)
},
languageOptions: {
globals: {
...globals.node,
...globals.jest
},
parser: tsParser,
ecmaVersion: 'latest',
sourceType: 'module'
},
rules: {
'@typescript-eslint/no-require-imports': [
'error',
{
allowAsImport: true
}
]
}
}
]);

View File

@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-require-imports */ import fs from 'fs';
const fs = require('fs'); import os from 'os';
const os = require('os'); import path from 'path';
const path = require('path');
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-build-push-action-')); const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-build-push-action-'));
@ -10,7 +9,9 @@ process.env = Object.assign({}, process.env, {
GITHUB_REPOSITORY: 'docker/build-push-action', GITHUB_REPOSITORY: 'docker/build-push-action',
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'), RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache') RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
}); }) as {
[key: string]: string;
};
module.exports = { module.exports = {
clearMocks: false, clearMocks: false,

View File

@ -26,26 +26,23 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"packageManager": "yarn@3.6.3", "packageManager": "yarn@3.6.3",
"dependencies": { "dependencies": {
"@actions/core": "^1.11.1", "@actions/core": "^1.10.1",
"@docker/actions-toolkit": "0.62.1", "@docker/actions-toolkit": "0.39.0",
"handlebars": "^4.7.7" "handlebars": "^4.7.7"
}, },
"devDependencies": { "devDependencies": {
"@eslint/compat": "^2.0.0", "@types/node": "^20.12.12",
"@eslint/eslintrc": "^3.3.3", "@typescript-eslint/eslint-plugin": "^7.9.0",
"@eslint/js": "^9.39.2", "@typescript-eslint/parser": "^7.9.0",
"@types/node": "^20.19.27", "@vercel/ncc": "^0.38.1",
"@typescript-eslint/eslint-plugin": "^8.50.0", "eslint": "^8.57.0",
"@typescript-eslint/parser": "^8.50.0", "eslint-config-prettier": "^9.1.0",
"@vercel/ncc": "^0.38.4", "eslint-plugin-jest": "^28.5.0",
"eslint": "^9.39.2", "eslint-plugin-prettier": "^5.1.3",
"eslint-config-prettier": "^10.1.8", "jest": "^29.7.0",
"eslint-plugin-jest": "^29.5.0", "prettier": "^3.2.5",
"eslint-plugin-prettier": "^5.5.4", "ts-jest": "^29.1.2",
"jest": "^30.2.0",
"prettier": "^3.7.4",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.9.3" "typescript": "^5.4.5"
} }
} }

View File

@ -17,7 +17,6 @@ export interface Inputs {
builder: string; builder: string;
'cache-from': string[]; 'cache-from': string[];
'cache-to': string[]; 'cache-to': string[];
call: string;
'cgroup-parent': string; 'cgroup-parent': string;
context: string; context: string;
file: string; file: string;
@ -54,7 +53,6 @@ export async function getInputs(): Promise<Inputs> {
builder: core.getInput('builder'), builder: core.getInput('builder'),
'cache-from': Util.getInputList('cache-from', {ignoreComma: true}), 'cache-from': Util.getInputList('cache-from', {ignoreComma: true}),
'cache-to': Util.getInputList('cache-to', {ignoreComma: true}), 'cache-to': Util.getInputList('cache-to', {ignoreComma: true}),
call: core.getInput('call'),
'cgroup-parent': core.getInput('cgroup-parent'), 'cgroup-parent': core.getInput('cgroup-parent'),
context: core.getInput('context') || Context.gitContext(), context: core.getInput('context') || Context.gitContext(),
file: core.getInput('file'), file: core.getInput('file'),
@ -81,6 +79,25 @@ export async function getInputs(): Promise<Inputs> {
}; };
} }
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;
}
res[key] = value;
}
return res;
}
export async function getArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> { export async function getArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
const context = handlebars.compile(inputs.context)({ const context = handlebars.compile(inputs.context)({
defaultContext: Context.gitContext() defaultContext: Context.gitContext()
@ -98,9 +115,9 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit):
await Util.asyncForEach(inputs['add-hosts'], async addHost => { await Util.asyncForEach(inputs['add-hosts'], async addHost => {
args.push('--add-host', addHost); args.push('--add-host', addHost);
}); });
await Util.asyncForEach(inputs.allow, async allow => { if (inputs.allow.length > 0) {
args.push('--allow', allow); args.push('--allow', inputs.allow.join(','));
}); }
if (await toolkit.buildx.versionSatisfies('>=0.12.0')) { if (await toolkit.buildx.versionSatisfies('>=0.12.0')) {
await Util.asyncForEach(inputs.annotations, async annotation => { await Util.asyncForEach(inputs.annotations, async annotation => {
args.push('--annotation', annotation); args.push('--annotation', annotation);
@ -113,12 +130,7 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit):
}); });
if (await toolkit.buildx.versionSatisfies('>=0.8.0')) { if (await toolkit.buildx.versionSatisfies('>=0.8.0')) {
await Util.asyncForEach(inputs['build-contexts'], async buildContext => { await Util.asyncForEach(inputs['build-contexts'], async buildContext => {
args.push( args.push('--build-context', buildContext);
'--build-context',
handlebars.compile(buildContext)({
defaultContext: Context.gitContext()
})
);
}); });
} else if (inputs['build-contexts'].length > 0) { } else if (inputs['build-contexts'].length > 0) {
core.warning("Build contexts are only supported by buildx >= 0.8.0; the input 'build-contexts' is ignored."); core.warning("Build contexts are only supported by buildx >= 0.8.0; the input 'build-contexts' is ignored.");
@ -129,12 +141,6 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit):
await Util.asyncForEach(inputs['cache-to'], async cacheTo => { await Util.asyncForEach(inputs['cache-to'], async cacheTo => {
args.push('--cache-to', cacheTo); args.push('--cache-to', cacheTo);
}); });
if (inputs.call) {
if (!(await toolkit.buildx.versionSatisfies('>=0.15.0'))) {
throw new Error(`Buildx >= 0.15.0 is required to use the call flag.`);
}
args.push('--call', inputs.call);
}
if (inputs['cgroup-parent']) { if (inputs['cgroup-parent']) {
args.push('--cgroup-parent', inputs['cgroup-parent']); args.push('--cgroup-parent', inputs['cgroup-parent']);
} }
@ -245,7 +251,7 @@ async function getAttestArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<st
if (inputs.provenance) { if (inputs.provenance) {
args.push('--attest', Build.resolveAttestationAttrs(`type=provenance,${inputs.provenance}`)); args.push('--attest', Build.resolveAttestationAttrs(`type=provenance,${inputs.provenance}`));
provenanceSet = true; provenanceSet = true;
} else if (!hasAttestProvenance && !noDefaultAttestations() && (await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !Build.hasDockerExporter(inputs.outputs, inputs.load)) { } else if (!hasAttestProvenance && (await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !Build.hasDockerExporter(inputs.outputs, inputs.load)) {
// if provenance not specified in provenance or attests inputs and BuildKit // if provenance not specified in provenance or attests inputs and BuildKit
// version compatible for attestation, set default provenance. Also needs // version compatible for attestation, set default provenance. Also needs
// to make sure user doesn't want to explicitly load the image to docker. // to make sure user doesn't want to explicitly load the image to docker.
@ -277,10 +283,3 @@ async function getAttestArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<st
return args; return args;
} }
function noDefaultAttestations(): boolean {
if (process.env.BUILDX_NO_DEFAULT_ATTESTATIONS) {
return Util.parseBool(process.env.BUILDX_NO_DEFAULT_ATTESTATIONS);
}
return false;
}

View File

@ -24,8 +24,8 @@ actionsToolkit.run(
async () => { async () => {
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();
@ -85,8 +85,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));
}); });
@ -106,14 +104,8 @@ actionsToolkit.run(
[key: string]: string; [key: string]: string;
} }
}).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) { err = Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
// checks warnings are printed to stdout: https://github.com/docker/buildx/pull/2647
// take the first line with the message summaryzing the warnings
err = new Error(res.stdout.split('\n')[0]?.trim());
} else if (res.stderr.length > 0) {
err = new Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
}
} }
}); });
@ -169,12 +161,12 @@ actionsToolkit.run(
await core.group(`Check build summary support`, async () => { await core.group(`Check build summary support`, async () => {
if (!buildSummaryEnabled()) { if (!buildSummaryEnabled()) {
core.info('Build summary disabled'); core.info('Build summary disabled');
} else if (inputs.call && inputs.call !== 'build') {
core.info(`Build summary skipped for ${inputs.call} subrequest`);
} else if (GitHub.isGHES) { } else if (GitHub.isGHES) {
core.info('Build summary is not yet supported on GHES'); core.info('Build summary is not yet supported on GHES');
} else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) { } else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) {
core.info('Build summary requires Buildx >= 0.13.0'); core.info('Build summary requires Buildx >= 0.13.0');
} else if (builder && builder.driver === 'cloud') {
core.info('Build summary is not yet supported with Docker Build Cloud');
} else if (!ref) { } else if (!ref) {
core.info('Build summary requires a build reference'); core.info('Build summary requires a build reference');
} else { } else {
@ -200,8 +192,7 @@ actionsToolkit.run(
const buildxHistory = new BuildxHistory(); const buildxHistory = new BuildxHistory();
const exportRes = await buildxHistory.export({ const exportRes = await buildxHistory.export({
refs: stateHelper.buildRef ? [stateHelper.buildRef] : [], refs: stateHelper.buildRef ? [stateHelper.buildRef] : []
useContainer: buildExportLegacy()
}); });
core.info(`Build record written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`); core.info(`Build record written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
@ -217,9 +208,7 @@ actionsToolkit.run(
await GitHub.writeBuildSummary({ await GitHub.writeBuildSummary({
exportRes: exportRes, exportRes: exportRes,
uploadRes: uploadRes, uploadRes: uploadRes,
inputs: stateHelper.summaryInputs, inputs: stateHelper.inputs
driver: stateHelper.builderDriver,
endpoint: stateHelper.builderEndpoint
}); });
} catch (e) { } catch (e) {
core.warning(e.message); core.warning(e.message);
@ -228,11 +217,7 @@ actionsToolkit.run(
} }
if (stateHelper.tmpDir.length > 0) { if (stateHelper.tmpDir.length > 0) {
await core.group(`Removing temp folder ${stateHelper.tmpDir}`, async () => { await core.group(`Removing temp folder ${stateHelper.tmpDir}`, async () => {
try { fs.rmSync(stateHelper.tmpDir, {recursive: true});
fs.rmSync(stateHelper.tmpDir, {recursive: true});
} catch {
core.warning(`Failed to remove temp folder ${stateHelper.tmpDir}`);
}
}); });
} }
} }
@ -292,15 +277,8 @@ function buildRecordRetentionDays(): number | undefined {
if (val) { if (val) {
const res = parseInt(val); const res = parseInt(val);
if (isNaN(res)) { if (isNaN(res)) {
throw new Error(`Invalid build record retention days: ${val}`); throw Error(`Invalid build record retention days: ${val}`);
} }
return res; return res;
} }
} }
function buildExportLegacy(): boolean {
if (process.env.DOCKER_BUILD_EXPORT_LEGACY) {
return Util.parseBool(process.env.DOCKER_BUILD_EXPORT_LEGACY);
}
return false;
}

View File

@ -1,15 +1,9 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import {Build} from '@docker/actions-toolkit/lib/buildx/build'; import {Inputs, sanitizeInputs} from './context';
import {Inputs} from './context';
export const tmpDir = process.env['STATE_tmpDir'] || ''; export const tmpDir = process.env['STATE_tmpDir'] || '';
export const inputs = process.env['STATE_inputs'] ? JSON.parse(process.env['STATE_inputs']) : undefined;
export const builderDriver = process.env['STATE_builderDriver'] || '';
export const builderEndpoint = process.env['STATE_builderEndpoint'] || '';
export const summaryInputs = process.env['STATE_summaryInputs'] ? JSON.parse(process.env['STATE_summaryInputs']) : undefined;
export const buildRef = process.env['STATE_buildRef'] || ''; export const buildRef = process.env['STATE_buildRef'] || '';
export const isSummarySupported = !!process.env['STATE_isSummarySupported']; export const isSummarySupported = !!process.env['STATE_isSummarySupported'];
@ -17,12 +11,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 setBuildRef(buildRef: string) { export function setBuildRef(buildRef: string) {
@ -32,39 +22,3 @@ export function setBuildRef(buildRef: string) {
export function setSummarySupported() { export function setSummarySupported() {
core.saveState('isSummarySupported', 'true'); core.saveState('isSummarySupported', 'true');
} }
export function setSummaryInputs(inputs: Inputs) {
const res = {};
for (const key of Object.keys(inputs)) {
if (key === 'github-token') {
continue;
}
const value: string | string[] | boolean = inputs[key];
if (typeof value === 'boolean' && !value) {
continue;
} else if (Array.isArray(value)) {
if (value.length === 0) {
continue;
} else if (key === 'secrets' && value.length > 0) {
const secretKeys: string[] = [];
for (const secret of value) {
try {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [skey, _] = Build.parseSecretKvp(secret, true);
secretKeys.push(skey);
} catch {
// ignore invalid secret
}
}
if (secretKeys.length > 0) {
res[key] = secretKeys;
}
continue;
}
} else if (!value) {
continue;
}
res[key] = value;
}
core.saveState('summaryInputs', JSON.stringify(res));
}

View File

@ -1,6 +1,5 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM golang:alpine AS build
FROM --platform=$BUILDPLATFORM alpine AS build
ARG TARGETPLATFORM ARG TARGETPLATFORM
ARG BUILDPLATFORM ARG BUILDPLATFORM
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" > /log RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" > /log
@ -13,7 +12,7 @@ RUN apk --update --no-cache add \
&& rm -rf /tmp/* /var/cache/apk/* && rm -rf /tmp/* /var/cache/apk/*
USER buildx USER buildx
RUN sudo chown buildx: /log RUN sudo chown buildx. /log
USER root USER root
FROM alpine FROM alpine

3700
yarn.lock

File diff suppressed because it is too large Load Diff