Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(ci-env): add ci.werf.io/tag automatic annotation (#5789)
Signed-off-by: Maksim Kiselev <maksim.kiselev@flant.com>
  • Loading branch information
trublast committed Sep 20, 2023
1 parent 834afee commit b36586f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/werf/ci_env/ci_env.go
Expand Up @@ -256,6 +256,13 @@ func generateGitlabEnvs(ctx context.Context, w io.Writer, dockerConfig string) e
}
writeEnv(w, "WERF_ADD_ANNOTATION_CI_COMMIT", ciCommit, true)

var ciGitTag string
ciCommitTag := os.Getenv("CI_COMMIT_TAG")
if ciCommitTag != "" {
ciGitTag = fmt.Sprintf("ci.werf.io/tag=%s", ciCommitTag)
}
writeEnv(w, "WERF_ADD_ANNOTATION_CI_GIT_TAG", ciGitTag, true)

var gitlabCIPipelineUrl string
ciPipelineIdEnv := os.Getenv("CI_PIPELINE_ID")
if ciProjectUrlEnv != "" && ciPipelineIdEnv != "" {
Expand Down Expand Up @@ -348,6 +355,14 @@ func generateGithubEnvs(ctx context.Context, w io.Writer, dockerConfig string) e
}
writeEnv(w, "WERF_ADD_ANNOTATION_CI_COMMIT", ciCommit, true)

var ciGitTag string
ciRefType := os.Getenv("GITHUB_REF_TYPE")
ciRefName := os.Getenv("GITHUB_REF_NAME")
if ciRefType == "tag" && ciRefName != "" {
ciGitTag = fmt.Sprintf("ci.werf.io/tag=%s", ciRefName)
}
writeEnv(w, "WERF_ADD_ANNOTATION_CI_GIT_TAG", ciGitTag, true)

var workflowRunUrl string
ciWorkflowRunIdEnv := os.Getenv("GITHUB_RUN_ID")
if ciGithubOwnerWithProject != "" && ciWorkflowRunIdEnv != "" {
Expand Down

0 comments on commit b36586f

Please sign in to comment.