diff --git a/.github/workflows/enterprise-pr-check.yml b/.github/workflows/enterprise-pr-check.yml index f5552fe9437..4a09cf0a54f 100644 --- a/.github/workflows/enterprise-pr-check.yml +++ b/.github/workflows/enterprise-pr-check.yml @@ -23,4 +23,4 @@ jobs: repository: grafana/grafana-enterprise event_type: oss-pull-request client_payload: - '{"source_branch": "${{ github.head_ref }}", "target_branch": "${{ github.base_ref }}", "pr_number": "${{ github.event.number }}"}' + '{"source_sha": "${{ github.sha }}", "source_branch": "${{ github.head_ref }}", "target_branch": "${{ github.base_ref }}", "pr_number": "${{ github.event.number }}"}' diff --git a/pkg/build/cmd/enterprisecheck.go b/pkg/build/cmd/enterprisecheck.go index 732ae728442..396c123df2d 100644 --- a/pkg/build/cmd/enterprisecheck.go +++ b/pkg/build/cmd/enterprisecheck.go @@ -18,9 +18,22 @@ type checkOpts struct { } func getCheckOpts(args []string) (*checkOpts, error) { + branch, ok := env.Lookup("DRONE_SOURCE_BRANCH", args) + if !ok { + return nil, cli.Exit("Unable to retrieve build source branch", 1) + } + + var ( + rgx = git.PRCheckRegexp() + matches = rgx.FindStringSubmatch(branch) + ) + sha, ok := env.Lookup("SOURCE_COMMIT", args) if !ok { - return nil, cli.Exit(`missing environment variable "SOURCE_COMMIT"`, 1) + if matches == nil || len(matches) <= 1 { + return nil, cli.Exit("Unable to retrieve source commit", 1) + } + sha = matches[2] } url, ok := env.Lookup("DRONE_BUILD_LINK", args) @@ -28,14 +41,8 @@ func getCheckOpts(args []string) (*checkOpts, error) { return nil, cli.Exit(`missing environment variable "DRONE_BUILD_LINK"`, 1) } - branch, ok := env.Lookup("DRONE_SOURCE_BRANCH", args) - if !ok { - return nil, cli.Exit("Unable to retrieve build source branch", 1) - } - prStr, ok := env.Lookup("OSS_PULL_REQUEST", args) if !ok { - matches := git.PRCheckRegexp().FindStringSubmatch(branch) if matches == nil || len(matches) <= 1 { return nil, cli.Exit("Unable to retrieve PR number", 1) }