From b7d6515f6f3eab38c6515ba2506b9d3f7c4b73af Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Wed, 18 Mar 2026 09:38:32 +0100 Subject: [PATCH] build/bake: use query format for git context Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- .github/workflows/bake.yml | 14 ++++++++++++-- .github/workflows/build.yml | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index a368700..570d59c 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -158,6 +158,7 @@ env: COSIGN_VERSION: "v3.0.2" LOCAL_EXPORT_DIR: "/tmp/buildx-output" MATRIX_SIZE_LIMIT: "20" + BUILDX_SEND_GIT_QUERY_AS_INPUT: "true" jobs: prepare: @@ -226,6 +227,14 @@ jobs: } }); } + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 + with: + version: ${{ env.BUILDX_VERSION }} + cache-binary: false + driver-opts: | + image=${{ env.BUILDKIT_IMAGE }} - name: Expose GitHub Runtime uses: crazy-max/ghaction-github-runtime@04d248b84655b509d8c44dc1d6f990c879747487 # v4.0.0 @@ -254,6 +263,7 @@ jobs: script: | const os = require('os'); const { Bake } = require('@docker/actions-toolkit/lib/buildx/bake'); + const { Build } = require('@docker/actions-toolkit/lib/buildx/build'); const { GitHub } = require('@docker/actions-toolkit/lib/github/github'); const { Util } = require('@docker/actions-toolkit/lib/util'); @@ -300,7 +310,7 @@ jobs: return; } - const bakeSource = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}.git#${process.env.GITHUB_REF}:${inpContext}`; + const bakeSource = await new Build().gitContext({subdir: inpContext}); await core.group(`Set bake source`, async () => { core.info(bakeSource); }); @@ -668,7 +678,7 @@ jobs: }; const renderTemplate = value => Handlebars.compile(value, {noEscape: true})({meta}); - const bakeSource = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}.git#${process.env.GITHUB_REF}:${inpContext}`; + const bakeSource = await new Build().gitContext({subdir: inpContext}); await core.group(`Set source output`, async () => { core.info(bakeSource); core.setOutput('source', bakeSource); diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d89cb0..afb8ccf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -161,6 +161,7 @@ env: COSIGN_VERSION: "v3.0.2" LOCAL_EXPORT_DIR: "/tmp/buildx-output" MATRIX_SIZE_LIMIT: "20" + BUILDX_SEND_GIT_QUERY_AS_INPUT: "true" jobs: prepare: @@ -570,7 +571,7 @@ jobs: const renderTemplate = value => Handlebars.compile(value, {noEscape: true})({meta}); const toMultilineInput = value => value.split(/\r?\n/).map(line => line.trim()).filter(Boolean); - const buildContext = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}.git#${process.env.GITHUB_REF}:${inpContext}`; + const buildContext = await new Build().gitContext({subdir: inpContext}); core.setOutput('context', buildContext); switch (inpOutput) {