Skip to content

Commit 80475a0

Browse files
committed
pass GITHUB_TOKEN as secret to docker build, if it is present
1 parent bd636e8 commit 80475a0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

framework/docker.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,18 +418,25 @@ func BuildImageOnce(once *sync.Once, dctx, dfile, nameAndTag string, buildArgs m
418418

419419
func BuildImage(dctx, dfile, nameAndTag string, buildArgs map[string]string) error {
420420
dfilePath := filepath.Join(dctx, dfile)
421+
421422
if os.Getenv("CTF_CLNODE_DLV") == "true" {
422423
commandParts := []string{"docker", "build", "--build-arg", `GO_GCFLAGS=all=-N -l`, "--build-arg", "CHAINLINK_USER=chainlink"}
423424
for k, v := range buildArgs {
424425
commandParts = append(commandParts, "--build-arg", fmt.Sprintf("%s=%s", k, v))
425426
}
427+
if os.Getenv("GITHUB_TOKEN") != "" {
428+
commandParts = append(commandParts, "--secret id=GIT_AUTH_TOKEN,env=GITHUB_TOKEN")
429+
}
426430
commandParts = append(commandParts, "-t", nameAndTag, "-f", dfilePath, dctx)
427431
return RunCommand(commandParts[0], commandParts[1:]...)
428432
}
429433
commandParts := []string{"docker", "build", "--build-arg", "CHAINLINK_USER=chainlink"}
430434
for k, v := range buildArgs {
431435
commandParts = append(commandParts, "--build-arg", fmt.Sprintf("%s=%s", k, v))
432436
}
437+
if os.Getenv("GITHUB_TOKEN") != "" {
438+
commandParts = append(commandParts, "--secret id=GIT_AUTH_TOKEN,env=GITHUB_TOKEN")
439+
}
433440
commandParts = append(commandParts, "-t", nameAndTag, "-f", dfilePath, dctx)
434441
return RunCommand(commandParts[0], commandParts[1:]...)
435442
}

0 commit comments

Comments
 (0)