Skip to content

Commit

Permalink
ci: Update DataDog GitHub branch to fallback to GITHUB_REF (#356)
Browse files Browse the repository at this point in the history
This was detecting branches, but not our "main" branch before.
Hopefully this fixes it!
  • Loading branch information
kylecarbs committed Feb 24, 2022
1 parent b913ea8 commit 41c3ee7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/datadog-cireport/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,16 @@ func main() {
}
commitParts := strings.Split(string(commitData), ",")

// On pull requests, this will be set!
branch := os.Getenv("GITHUB_HEAD_REF")
if branch == "" {
branch = os.Getenv("GITHUB_BASE_REF")
githubRef := os.Getenv("GITHUB_REF")
for _, prefix := range []string{"refs/heads/", "refs/tags/"} {
if !strings.HasPrefix(githubRef, prefix) {
continue
}
branch = strings.TrimPrefix(githubRef, prefix)
}
}

tags := map[string]string{
Expand Down

0 comments on commit 41c3ee7

Please sign in to comment.