Skip to content

Commit e2cbf1f

Browse files
committed
build/bake: use query format for git context
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 36c3912 commit e2cbf1f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.github/workflows/bake.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ env:
158158
COSIGN_VERSION: "v3.0.2"
159159
LOCAL_EXPORT_DIR: "/tmp/buildx-output"
160160
MATRIX_SIZE_LIMIT: "20"
161+
BUILDX_SEND_GIT_QUERY_AS_INPUT: "true"
161162

162163
jobs:
163164
prepare:
@@ -226,6 +227,14 @@ jobs:
226227
}
227228
});
228229
}
230+
-
231+
name: Set up Docker Buildx
232+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
233+
with:
234+
version: ${{ env.BUILDX_VERSION }}
235+
cache-binary: false
236+
driver-opts: |
237+
image=${{ env.BUILDKIT_IMAGE }}
229238
-
230239
name: Expose GitHub Runtime
231240
uses: crazy-max/ghaction-github-runtime@04d248b84655b509d8c44dc1d6f990c879747487 # v4.0.0
@@ -254,6 +263,7 @@ jobs:
254263
script: |
255264
const os = require('os');
256265
const { Bake } = require('@docker/actions-toolkit/lib/buildx/bake');
266+
const { Build, GitContextOpts } = require('@docker/actions-toolkit/lib/buildx/build');
257267
const { GitHub } = require('@docker/actions-toolkit/lib/github/github');
258268
const { Util } = require('@docker/actions-toolkit/lib/util');
259269
@@ -300,7 +310,7 @@ jobs:
300310
return;
301311
}
302312
303-
const bakeSource = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}.git#${process.env.GITHUB_REF}:${inpContext}`;
313+
const bakeSource = await new Build().gitContext({subdir: inpContext});
304314
await core.group(`Set bake source`, async () => {
305315
core.info(bakeSource);
306316
});
@@ -668,7 +678,7 @@ jobs:
668678
};
669679
const renderTemplate = value => Handlebars.compile(value, {noEscape: true})({meta});
670680
671-
const bakeSource = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}.git#${process.env.GITHUB_REF}:${inpContext}`;
681+
const bakeSource = await new Build().gitContext({subdir: inpContext});
672682
await core.group(`Set source output`, async () => {
673683
core.info(bakeSource);
674684
core.setOutput('source', bakeSource);

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ env:
161161
COSIGN_VERSION: "v3.0.2"
162162
LOCAL_EXPORT_DIR: "/tmp/buildx-output"
163163
MATRIX_SIZE_LIMIT: "20"
164+
BUILDX_SEND_GIT_QUERY_AS_INPUT: "true"
164165

165166
jobs:
166167
prepare:
@@ -570,7 +571,7 @@ jobs:
570571
const renderTemplate = value => Handlebars.compile(value, {noEscape: true})({meta});
571572
const toMultilineInput = value => value.split(/\r?\n/).map(line => line.trim()).filter(Boolean);
572573
573-
const buildContext = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}.git#${process.env.GITHUB_REF}:${inpContext}`;
574+
const buildContext = await new Build().gitContext({subdir: inpContext});
574575
core.setOutput('context', buildContext);
575576
576577
switch (inpOutput) {

0 commit comments

Comments
 (0)