Skip to content

Commit 682c34d

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

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

framework/docker.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,19 +418,27 @@ 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+
422+
extraParameters := []string{}
423+
if os.Getenv("GITHUB_TOKEN") != "" {
424+
extraParameters = append(extraParameters, "--secret id=GIT_AUTH_TOKEN,env=GITHUB_TOKEN")
425+
}
426+
421427
if os.Getenv("CTF_CLNODE_DLV") == "true" {
422428
commandParts := []string{"docker", "build", "--build-arg", `GO_GCFLAGS=all=-N -l`, "--build-arg", "CHAINLINK_USER=chainlink"}
423429
for k, v := range buildArgs {
424430
commandParts = append(commandParts, "--build-arg", fmt.Sprintf("%s=%s", k, v))
425431
}
426432
commandParts = append(commandParts, "-t", nameAndTag, "-f", dfilePath, dctx)
433+
commandParts = append(commandParts, extraParameters...)
427434
return RunCommand(commandParts[0], commandParts[1:]...)
428435
}
429436
commandParts := []string{"docker", "build", "--build-arg", "CHAINLINK_USER=chainlink"}
430437
for k, v := range buildArgs {
431438
commandParts = append(commandParts, "--build-arg", fmt.Sprintf("%s=%s", k, v))
432439
}
433440
commandParts = append(commandParts, "-t", nameAndTag, "-f", dfilePath, dctx)
441+
commandParts = append(commandParts, extraParameters...)
434442
return RunCommand(commandParts[0], commandParts[1:]...)
435443
}
436444

0 commit comments

Comments
 (0)