Skip to content

Commit

Permalink
chore: only set CI_ARGS for ghactions
Browse files Browse the repository at this point in the history
Only set `CI_ARGS` for GitHub actions.

Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
frezbo committed Sep 18, 2023
1 parent d662e64 commit 0bf4591
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions internal/project/common/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,19 @@ func (docker *Docker) CompileMakefile(output *makefile.Output) error {
Variable(makefile.OverridableVariable("CI_ARGS", "")).
Variable(buildArgs)

cacheTypeBranch := "type=registry,ref=" + cacheImage + ":" + "buildcache-" + "$(GITHUB_BRANCH)"

output.IfTrueCondition("CI").
Then(
makefile.SimpleVariable("GITHUB_BRANCH", "$(subst /,-,${GITHUB_HEAD_REF})"),
makefile.SimpleVariable("GITHUB_BRANCH", "$(subst +,-,$(GITHUB_BRANCH))"),
makefile.SimpleVariable(
"CI_ARGS",
fmt.Sprintf("--cache-from=%s --cache-from=%s --cache-to=%s,mode=max", cacheTypeMain, cacheTypeBranch, cacheTypeBranch),
),
)
if docker.meta.CIProvider == config.CIProviderGitHubActions {
cacheTypeBranch := "type=registry,ref=" + cacheImage + ":" + "buildcache-" + "$(GITHUB_BRANCH)"

output.IfTrueCondition("CI").
Then(
makefile.SimpleVariable("GITHUB_BRANCH", "$(subst /,-,${GITHUB_HEAD_REF})"),
makefile.SimpleVariable("GITHUB_BRANCH", "$(subst +,-,$(GITHUB_BRANCH))"),
makefile.SimpleVariable(
"CI_ARGS",
fmt.Sprintf("--cache-from=%s --cache-from=%s --cache-to=%s,mode=max", cacheTypeMain, cacheTypeBranch, cacheTypeBranch),
),
)
}

output.Target("target-%").
Description("Builds the specified target defined in the Dockerfile. The build result will only remain in the build cache.").
Expand Down

0 comments on commit 0bf4591

Please sign in to comment.