ci: Use GITHUB_BASE_REF as backup if branch isn't set for DataDog (#321)

The change in #313 caused PRs to report "<id>/merge" as the name.
This commit is contained in:
Kyle Carberry 2022-02-18 11:19:06 -06:00 committed by GitHub
parent 6170421044
commit 5bfdb0cf98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -59,6 +59,11 @@ func main() {
}
commitParts := strings.Split(string(commitData), ",")
branch := os.Getenv("GITHUB_HEAD_REF")
if branch == "" {
branch = os.Getenv("GITHUB_BASE_REF")
}
tags := map[string]string{
"service": "coder",
"_dd.cireport_version": "2",
@ -78,7 +83,7 @@ func main() {
"ci.provider.name": "github",
"ci.workspace_path": os.Getenv("GITHUB_WORKSPACE"),
"git.branch": os.Getenv("GITHUB_REF_NAME"),
"git.branch": branch,
"git.commit.sha": githubSHA,
"git.repository_url": fmt.Sprintf("%s/%s.git", githubServerURL, githubRepository),