CI: add source_sha option to enterprise-pr-check action (#59314)

* add source_sha option to enterprise-pr-check action

* Add git hash to enterprise check branch
pull/59578/head
Kevin Minehart 3 years ago committed by GitHub
parent 40d87d9d40
commit b3b7cba0fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/workflows/enterprise-pr-check.yml
  2. 21
      pkg/build/cmd/enterprisecheck.go

@ -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 }}"}'

@ -18,24 +18,31 @@ type checkOpts struct {
}
func getCheckOpts(args []string) (*checkOpts, error) {
sha, ok := env.Lookup("SOURCE_COMMIT", args)
branch, ok := env.Lookup("DRONE_SOURCE_BRANCH", args)
if !ok {
return nil, cli.Exit(`missing environment variable "SOURCE_COMMIT"`, 1)
return nil, cli.Exit("Unable to retrieve build source branch", 1)
}
url, ok := env.Lookup("DRONE_BUILD_LINK", args)
var (
rgx = git.PRCheckRegexp()
matches = rgx.FindStringSubmatch(branch)
)
sha, ok := env.Lookup("SOURCE_COMMIT", args)
if !ok {
return nil, cli.Exit(`missing environment variable "DRONE_BUILD_LINK"`, 1)
if matches == nil || len(matches) <= 1 {
return nil, cli.Exit("Unable to retrieve source commit", 1)
}
sha = matches[2]
}
branch, ok := env.Lookup("DRONE_SOURCE_BRANCH", args)
url, ok := env.Lookup("DRONE_BUILD_LINK", args)
if !ok {
return nil, cli.Exit("Unable to retrieve build source branch", 1)
return nil, cli.Exit(`missing environment variable "DRONE_BUILD_LINK"`, 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)
}

Loading…
Cancel
Save