Skip to content

Commit 00fec87

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 00fec87

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

.github/workflows/bake.yml

Lines changed: 4 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:
@@ -254,6 +255,7 @@ jobs:
254255
script: |
255256
const os = require('os');
256257
const { Bake } = require('@docker/actions-toolkit/lib/buildx/bake');
258+
const { Build } = require('@docker/actions-toolkit/lib/buildx/build');
257259
const { GitHub } = require('@docker/actions-toolkit/lib/github/github');
258260
const { Util } = require('@docker/actions-toolkit/lib/util');
259261
@@ -300,7 +302,7 @@ jobs:
300302
return;
301303
}
302304
303-
const bakeSource = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}.git#${process.env.GITHUB_REF}:${inpContext}`;
305+
const bakeSource = await new Build().gitContext({subdir: inpContext});
304306
await core.group(`Set bake source`, async () => {
305307
core.info(bakeSource);
306308
});
@@ -668,7 +670,7 @@ jobs:
668670
};
669671
const renderTemplate = value => Handlebars.compile(value, {noEscape: true})({meta});
670672
671-
const bakeSource = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}.git#${process.env.GITHUB_REF}:${inpContext}`;
673+
const bakeSource = await new Build().gitContext({subdir: inpContext});
672674
await core.group(`Set source output`, async () => {
673675
core.info(bakeSource);
674676
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)