From 41d7521b97ed027b1157dc520888590490970d89 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Fri, 26 Jul 2024 18:00:07 +0800 Subject: [PATCH] Support `pull_request_target` event for commit status (#31703) Fix [act_runner #573](https://gitea.com/gitea/act_runner/issues/573) Before: ![image](https://github.com/user-attachments/assets/3944bf7f-7a60-4801-bcb3-5e158a180fda) After: ![image](https://github.com/user-attachments/assets/cadac944-40bd-4537-a9d9-e702b8bc1ece) (cherry picked from commit 4b376a0ed934ba77d91ab182215fcff07b13c8df) Conflicts: services/actions/commit_status.go trivial context conflict --- services/actions/commit_status.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/actions/commit_status.go b/services/actions/commit_status.go index bc2905e08..2698059e9 100644 --- a/services/actions/commit_status.go +++ b/services/actions/commit_status.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/models/db" git_model "code.gitea.io/gitea/models/git" user_model "code.gitea.io/gitea/models/user" + actions_module "code.gitea.io/gitea/modules/actions" "code.gitea.io/gitea/modules/log" api "code.gitea.io/gitea/modules/structs" webhook_module "code.gitea.io/gitea/modules/webhook" @@ -53,7 +54,11 @@ func createCommitStatus(ctx context.Context, job *actions_model.ActionRunJob) er } sha = payload.HeadCommit.ID case webhook_module.HookEventPullRequest, webhook_module.HookEventPullRequestSync: - event = "pull_request" + if run.TriggerEvent == actions_module.GithubEventPullRequestTarget { + event = "pull_request_target" + } else { + event = "pull_request" + } payload, err := run.GetPullRequestEventPayload() if err != nil { return fmt.Errorf("GetPullRequestEventPayload: %w", err)