Replies: 1 comment
-
@MrHinsh did you solve this anyway? My understanding is that this is fundamentally driven by the GITHUB_REF environment variable when building in a GHA agent. I don't think its possible to override this variable in GHA, and I don't know if its possible to override it any other way... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a public repo, and in order to build with secrets I just switched to
pull_request_target
and GitVersion thinks its on main! (it also jumped a major version, which I don't know why).Id appreciate any help from someone that has already tried this!
Here’s a table that illustrates the difference in behavior of
GitVersion_BranchName
when usingpull_request
vs.pull_request_target
in GitHub Actions.GitVersion_BranchName
Output Examplepull_request
pull/2439/merge
pull_request
, GitHub Actions runs in the context of the PR branch, hence the branch name will be formatted aspull/{PR number}/merge
.pull_request_target
main
pull_request_target
, GitHub Actions runs in the context of the base branch (e.g.,main
), not the PR branch. Therefore,GitVersion_BranchName
will be set tomain
.Key Differences:
pull_request
: The workflow runs in the context of the pull request (head) branch, andGitVersion_BranchName
will be formatted withpull/{PR number}/merge
.pull_request_target
: The workflow runs in the context of the base branch (the branch being targeted by the PR), andGitVersion_BranchName
reflects the base branch name, such asmain
.This behavior is due to the fact that
pull_request_target
uses the base branch’s context (which allows access to secrets), whilepull_request
uses the context of the pull request’s head branch.Triggers:
workflow:
Gitversion.yaml
Beta Was this translation helpful? Give feedback.
All reactions