Skip to content

Commit fb79819

Browse files
committed
set url and token
1 parent 6fd824a commit fb79819

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

framework/docker.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,25 @@ func BuildImageOnce(once *sync.Once, dctx, dfile, nameAndTag string) error {
267267
var err error
268268
once.Do(func() {
269269
dfilePath := filepath.Join(dctx, dfile)
270+
271+
githubServerURL := os.Getenv("GITHUB_SERVER_URL")
272+
githubRepository := os.Getenv("GITHUB_REPOSITORY")
273+
githubToken := os.Getenv("GITHUB_TOKEN")
274+
275+
if githubServerURL == "" || githubRepository == "" || githubToken == "" {
276+
L.Fatal().Err(err).Msg("Required environment variables are missing: GITHUB_SERVER_URL, GITHUB_REPOSITORY, GITHUB_TOKEN")
277+
return
278+
}
279+
280+
// Construct the cache URL
281+
cacheURL := fmt.Sprintf("%s/%s", githubServerURL, githubRepository)
270282
err = runCommand(
271283
"docker",
272284
"build",
273285
"--cache-from",
274-
"type=gha,scope=ctfdocker",
286+
fmt.Sprintf("type=gha,url=%s,token=%s,scope=ctfdocker", cacheURL, githubToken),
275287
"--cache-to",
276-
"type=gha,scope=ctfdocker,mode=max",
288+
fmt.Sprintf("type=gha,url=%s,token=%s,scope=ctfdocker,mode=max", cacheURL, githubToken),
277289
"-t",
278290
nameAndTag,
279291
"-f",

0 commit comments

Comments
 (0)