From 824bb3b2c03f1002e9db79567526d410eb383b88 Mon Sep 17 00:00:00 2001 From: sillyguodong Date: Fri, 24 Mar 2023 15:51:29 +0800 Subject: [PATCH 1/2] create commit status when event is pr sync --- models/actions/run.go | 7 ++++++- services/actions/commit_status.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/models/actions/run.go b/models/actions/run.go index a711cfee2ecd5..852c421956bc6 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -129,7 +129,7 @@ func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error) { } func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, error) { - if run.Event == webhook_module.HookEventPullRequest { + if run.Event == webhook_module.HookEventPullRequest || run.Event == webhook_module.HookEventPullRequestSync { var payload api.PullRequestPayload if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil { return nil, err @@ -139,6 +139,11 @@ func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, err return nil, fmt.Errorf("event %s is not a pull request event", run.Event) } +func (run *ActionRun) GetPullRequestSyncEventPayload() error { + + return nil +} + func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error { _, err := db.GetEngine(ctx).ID(repo.ID). SetExpr("num_action_runs", diff --git a/services/actions/commit_status.go b/services/actions/commit_status.go index 84de106eeca32..6604a149a5c93 100644 --- a/services/actions/commit_status.go +++ b/services/actions/commit_status.go @@ -45,7 +45,7 @@ func CreateCommitStatus(ctx context.Context, job *actions_model.ActionRunJob) er sha = payload.HeadCommit.ID creatorID = payload.Pusher.ID - case webhook_module.HookEventPullRequest: + case webhook_module.HookEventPullRequest, webhook_module.HookEventPullRequestSync: payload, err := run.GetPullRequestEventPayload() if err != nil { return fmt.Errorf("GetPullRequestEventPayload: %w", err) From aa4e34679ad5741a112461ecbb5ebd456fa76c42 Mon Sep 17 00:00:00 2001 From: sillyguodong Date: Fri, 24 Mar 2023 16:19:23 +0800 Subject: [PATCH 2/2] clean --- models/actions/run.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/models/actions/run.go b/models/actions/run.go index 852c421956bc6..1af8f897fa08a 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -139,11 +139,6 @@ func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, err return nil, fmt.Errorf("event %s is not a pull request event", run.Event) } -func (run *ActionRun) GetPullRequestSyncEventPayload() error { - - return nil -} - func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error { _, err := db.GetEngine(ctx).ID(repo.ID). SetExpr("num_action_runs",