From 92c2ccf7c262f02ee208ad74abd256ec2234ebcb Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 18 Feb 2022 15:08:31 +0000 Subject: [PATCH] ci: Use GITHUB_BASE_REF as backup if branch isn't set for DataDog The change in #313 caused PRs to report "/merge" as the name. --- scripts/datadog-cireport/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/datadog-cireport/main.go b/scripts/datadog-cireport/main.go index 302b077113bdb..2c0b3a3e67844 100644 --- a/scripts/datadog-cireport/main.go +++ b/scripts/datadog-cireport/main.go @@ -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),