fix: align github.ref to GitHub Action (#1362)

* fix: align github.ref to GitHub Action

The `github.ref` value should be `refs/heads/branch` in most cases.
There are a few exceptions handled by the code.

This change prefixes the default case with `refs/heads` and adds
tests for this and the excpetional cases.

* fix: correct existing assertions
This commit is contained in:
Markus Wolf
2022-09-27 00:49:19 +02:00
committed by GitHub
parent 7d0407fa4a
commit 97c083e902
4 changed files with 52 additions and 7 deletions

View File

@@ -486,7 +486,7 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
}
}
if ghc.EventName == "pull_request" {
if ghc.EventName == "pull_request" || ghc.EventName == "pull_request_target" {
ghc.BaseRef = asString(nestedMapLookup(ghc.Event, "pull_request", "base", "ref"))
ghc.HeadRef = asString(nestedMapLookup(ghc.Event, "pull_request", "head", "ref"))
}