Merge pull request '[PORT] add skip ci support for pull request title (#29774)' (#2701) from earl-warren/forgejo:wip-gitea-skip-ci into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2701 Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org>
This commit is contained in:
commit
468b879fe8
5 changed files with 57 additions and 11 deletions
|
@ -154,7 +154,7 @@ func notify(ctx context.Context, input *notifyInput) error {
|
|||
return fmt.Errorf("gitRepo.GetCommit: %w", err)
|
||||
}
|
||||
|
||||
if skipWorkflowsForCommit(input, commit) {
|
||||
if skipWorkflows(input, commit) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -232,8 +232,8 @@ func SkipPullRequestEvent(ctx context.Context, event webhook_module.HookEventTyp
|
|||
return exist
|
||||
}
|
||||
|
||||
func skipWorkflowsForCommit(input *notifyInput, commit *git.Commit) bool {
|
||||
// skip workflow runs with a configured skip-ci string in commit message if the event is push or pull_request(_sync)
|
||||
func skipWorkflows(input *notifyInput, commit *git.Commit) bool {
|
||||
// skip workflow runs with a configured skip-ci string in commit message or pr title if the event is push or pull_request(_sync)
|
||||
// https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs
|
||||
skipWorkflowEvents := []webhook_module.HookEventType{
|
||||
webhook_module.HookEventPush,
|
||||
|
@ -242,6 +242,10 @@ func skipWorkflowsForCommit(input *notifyInput, commit *git.Commit) bool {
|
|||
}
|
||||
if slices.Contains(skipWorkflowEvents, input.Event) {
|
||||
for _, s := range setting.Actions.SkipWorkflowStrings {
|
||||
if input.PullRequest != nil && strings.Contains(input.PullRequest.Issue.Title, s) {
|
||||
log.Debug("repo %s: skipped run for pr %v because of %s string", input.Repo.RepoPath(), input.PullRequest.Issue.ID, s)
|
||||
return true
|
||||
}
|
||||
if strings.Contains(commit.CommitMessage, s) {
|
||||
log.Debug("repo %s with commit %s: skipped run because of %s string", input.Repo.RepoPath(), commit.ID, s)
|
||||
return true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue