Merge pull request #284 from crazy-max/fix-git-auth-token
Some checks failed
ci-subaction / list-targets-group (push) Has been cancelled
ci / provenance (false) (push) Has been cancelled
ci-subaction / list-targets-group-matrix (push) Has been cancelled
ci-subaction / list-targets-multi-files (push) Has been cancelled
ci / bake (default) (push) Has been cancelled
ci / bake (release) (push) Has been cancelled
ci / error-msg (push) Has been cancelled
ci / provenance (mode=max) (push) Has been cancelled
ci / error-check (push) Has been cancelled
ci / standalone (push) Has been cancelled
ci / remote (push) Has been cancelled
ci / provenance () (push) Has been cancelled
ci / provenance (builder-id=foo) (push) Has been cancelled
ci / provenance (true) (push) Has been cancelled
ci / sbom (/tmp/bake-build, binary) (push) Has been cancelled
ci / sbom (type=image,name=localhost:5000/name/app:latest,push=true, image) (push) Has been cancelled
ci / set (push) Has been cancelled
ci / group (push) Has been cancelled
ci / docker-config-malformed (push) Has been cancelled
ci / proxy-docker-config (push) Has been cancelled
ci / proxy-buildkitd (push) Has been cancelled
ci / git-context (push) Has been cancelled
ci / git-context-and-local (push) Has been cancelled
ci / multi-output (push) Has been cancelled
ci / load-and-push (push) Has been cancelled
ci / summary-disable (push) Has been cancelled
ci / summary-disable-deprecated (push) Has been cancelled
ci / summary-not-supported (push) Has been cancelled
ci / record-upload-disable (push) Has been cancelled
ci / record-retention-days (0) (push) Has been cancelled
ci / record-retention-days (2) (push) Has been cancelled
ci / checks (latest) (push) Has been cancelled
ci / checks (v0.14.1) (push) Has been cancelled
ci / annotations-disabled (push) Has been cancelled
ci / allow (v0.17.1) (push) Has been cancelled
ci / allow (v0.18.0) (push) Has been cancelled
ci / allow (v0.19.0-rc2) (push) Has been cancelled
Some checks failed
ci-subaction / list-targets-group (push) Has been cancelled
ci / provenance (false) (push) Has been cancelled
ci-subaction / list-targets-group-matrix (push) Has been cancelled
ci-subaction / list-targets-multi-files (push) Has been cancelled
ci / bake (default) (push) Has been cancelled
ci / bake (release) (push) Has been cancelled
ci / error-msg (push) Has been cancelled
ci / provenance (mode=max) (push) Has been cancelled
ci / error-check (push) Has been cancelled
ci / standalone (push) Has been cancelled
ci / remote (push) Has been cancelled
ci / provenance () (push) Has been cancelled
ci / provenance (builder-id=foo) (push) Has been cancelled
ci / provenance (true) (push) Has been cancelled
ci / sbom (/tmp/bake-build, binary) (push) Has been cancelled
ci / sbom (type=image,name=localhost:5000/name/app:latest,push=true, image) (push) Has been cancelled
ci / set (push) Has been cancelled
ci / group (push) Has been cancelled
ci / docker-config-malformed (push) Has been cancelled
ci / proxy-docker-config (push) Has been cancelled
ci / proxy-buildkitd (push) Has been cancelled
ci / git-context (push) Has been cancelled
ci / git-context-and-local (push) Has been cancelled
ci / multi-output (push) Has been cancelled
ci / load-and-push (push) Has been cancelled
ci / summary-disable (push) Has been cancelled
ci / summary-disable-deprecated (push) Has been cancelled
ci / summary-not-supported (push) Has been cancelled
ci / record-upload-disable (push) Has been cancelled
ci / record-retention-days (0) (push) Has been cancelled
ci / record-retention-days (2) (push) Has been cancelled
ci / checks (latest) (push) Has been cancelled
ci / checks (v0.14.1) (push) Has been cancelled
ci / annotations-disabled (push) Has been cancelled
ci / allow (v0.17.1) (push) Has been cancelled
ci / allow (v0.18.0) (push) Has been cancelled
ci / allow (v0.19.0-rc2) (push) Has been cancelled
set GIT_AUTH_TOKEN secret if Git context used
This commit is contained in:
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@@ -729,6 +729,7 @@ jobs:
|
||||
name: Build
|
||||
uses: ./
|
||||
with:
|
||||
source: .
|
||||
files: |
|
||||
./test/config.hcl
|
||||
allow: network.host
|
||||
|
||||
2
dist/index.js
generated
vendored
2
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -68,6 +68,10 @@ export function sanitizeInputs(inputs: Inputs) {
|
||||
return res;
|
||||
}
|
||||
|
||||
export function getGitAuthToken(inputs: Inputs): string {
|
||||
return process.env.BUILDX_BAKE_GIT_AUTH_TOKEN ?? inputs['github-token'];
|
||||
}
|
||||
|
||||
export async function getArgs(inputs: Inputs, definition: BakeDefinition, toolkit: Toolkit): Promise<Array<string>> {
|
||||
// prettier-ignore
|
||||
return [
|
||||
@@ -97,6 +101,15 @@ async function getBakeArgs(inputs: Inputs, definition: BakeDefinition, toolkit:
|
||||
await Util.asyncForEach(inputs.set, async set => {
|
||||
args.push('--set', set);
|
||||
});
|
||||
if (await toolkit.buildx.versionSatisfies('<0.20.0')) {
|
||||
// For buildx versions < 0.20.0, we need to set GIT_AUTH_TOKEN secret as it
|
||||
// doesn't infer BUILDX_BAKE_GIT_AUTH_TOKEN environment variable for build
|
||||
// request: https://github.com/docker/buildx/pull/2905
|
||||
const gitAuthToken = getGitAuthToken(inputs);
|
||||
if (gitAuthToken && !Bake.hasGitAuthTokenSecret(definition) && inputs.source.startsWith(Context.gitContext())) {
|
||||
args.push('--set', `*.secrets=${Build.resolveSecretString(`GIT_AUTH_TOKEN=${gitAuthToken}`)}`);
|
||||
}
|
||||
}
|
||||
if (await toolkit.buildx.versionSatisfies('>=0.6.0')) {
|
||||
args.push('--metadata-file', toolkit.buildxBake.getMetadataFilePath());
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ actionsToolkit.run(
|
||||
stateHelper.setInputs(inputs);
|
||||
|
||||
const toolkit = new Toolkit();
|
||||
const gitAuthToken = process.env.BUILDX_BAKE_GIT_AUTH_TOKEN ?? inputs['github-token'];
|
||||
const gitAuthToken = context.getGitAuthToken(inputs);
|
||||
|
||||
await core.group(`GitHub Actions runtime token ACs`, async () => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user