Improve workflow event triggers (#23613)

Follow #23037 
Fix [#22598
comment](https://github.com/go-gitea/gitea/issues/22958#issuecomment-1475763042)

Workflows with `pull_request` trigger event can't be triggered by
`pull_request_sync` event. This PR adds the `canGithubEventMatch`
function to check if a Github event can match any Gitea event. If the
Github event matches a Gitea event, the related workflows should be
triggered.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
Zettat123 2023-03-23 12:04:15 +08:00 committed by GitHub
parent 389e83f7eb
commit e7f0bcf884
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 155 additions and 13 deletions

View file

@ -99,7 +99,7 @@ func DetectWorkflows(commit *git.Commit, triggedEvent webhook_module.HookEventTy
}
func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType, payload api.Payloader, evt *jobparser.Event) bool {
if convertFromGithubEvent(evt) != string(triggedEvent) {
if !canGithubEventMatch(evt.Name, triggedEvent) {
return false
}