File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,17 @@ func gitGetHead(workspaceDir string) (string, error) {
2727
2828 // Check if it is a GitHub Action Environment, If it is then get
2929 // the HEAD from `GITHUB_SHA` environment
30- _ , isGitHubEnv := os .LookupEnv ("GITHUB_ACTIONS" )
31-
32- if isGitHubEnv {
33- return os .Getenv ("GITHUB_SHA" ), nil
30+ if _ , isGitHubEnv := os .LookupEnv ("GITHUB_ACTIONS" ); isGitHubEnv {
31+ // When GITHUB_REF is not set, GITHUB_SHA points to original commit.
32+ // When set, it points to the "latest *merge* commit in the branch".
33+ // Ref: https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request
34+ if _ , isBranchCommit := os .LookupEnv ("GITHUB_REF" ); ! isBranchCommit {
35+ return os .Getenv ("GITHUB_SHA" ), nil
36+ }
3437 }
3538
36- // If we are here, it means this is neither GitHub Action env nor a travis env
37- // with PR. Continue to fetch the headOID via the git command.
39+ // If we are here, it means this is neither GitHub Action on default branch,
40+ // nor a travis env with PR. Continue to fetch the headOID via the git command.
3841 headOID := ""
3942
4043 cmd := exec .Command ("git" , "--no-pager" , "rev-parse" , "HEAD" )
You can’t perform that action at this time.
0 commit comments