You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 using pull_request vs. pull_request_target in GitHub Actions.
GitHub Action Trigger
GitVersion_BranchName Output Example
Explanation
pull_request
pull/2439/merge
When using pull_request, GitHub Actions runs in the context of the PR branch, hence the branch name will be formatted as pull/{PR number}/merge.
pull_request_target
main
When using 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 to main.
Key Differences:
pull_request: The workflow runs in the context of the pull request (head) branch, and GitVersion_BranchName will be formatted with pull/{PR number}/merge.
pull_request_target: The workflow runs in the context of the base branch (the branch being targeted by the PR), and GitVersion_BranchName reflects the base branch name, such as main.
This behavior is due to the fact that pull_request_target uses the base branch’s context (which allows access to secrets), while pull_request uses the context of the pull request’s head branch.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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