mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-15 04:46:01 +00:00
fix(actions): use base branch ref for pull_request_target context (#38636)
Fixes a bug in Actions context generation for `pull_request_target` workflows where `github.ref` / `gitea.ref` was incorrectly populated with `refs/heads/owner:branch` instead of `refs/heads/branch`. ### Problem Statement In `services/actions/context.go`, when constructing the `ref` string for `pull_request_target` events: ```go ref = git.BranchPrefix + pullPayload.PullRequest.Base.Name Signed-off-by: Sudhanshu Singh <sudhanshuwriterblc@gmail.com> Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -49,7 +49,7 @@ func GenerateGiteaContext(ctx context.Context, run *actions_model.ActionRun, att
|
||||
// In GitHub's documentation, ref should be the branch or tag that triggered workflow. But when the TriggerEvent is pull_request_target,
|
||||
// the ref will be the base branch.
|
||||
if run.TriggerEvent == actions_module.GithubEventPullRequestTarget {
|
||||
ref = git.BranchPrefix + pullPayload.PullRequest.Base.Name
|
||||
ref = git.BranchPrefix + pullPayload.PullRequest.Base.Ref
|
||||
sha = pullPayload.PullRequest.Base.Sha
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user