Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add skip ci functionality #28075

Merged
merged 16 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
parameters
  • Loading branch information
denyskon committed Nov 17, 2023
commit e371c3c330c1992bc0efcb9813714f60bae227fe
2 changes: 1 addition & 1 deletion docs/content/administration/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ PROXY_HOSTS = *.github.com
- `ZOMBIE_TASK_TIMEOUT`: **10m**: Timeout to stop the task which have running status, but haven't been updated for a long time
- `ENDLESS_TASK_TIMEOUT`: **3h**: Timeout to stop the tasks which have running status and continuous updates, but don't end for a long time
- `ABANDONED_JOB_TIMEOUT`: **24h**: Timeout to cancel the jobs which have waiting status, but haven't been picked by a runner for a long time
- `SKIP_RUN_STRINGS`: **[skip ci]**, **[ci skip]**, **[no ci]**, **[skip actions]**, **[actions skip]**: Strings committers can place inside a commit message to skip executing the corresponding actions workflow
- `SKIP_WORKFLOW_STRINGS`: **[skip ci]**, **[ci skip]**, **[no ci]**, **[skip actions]**, **[actions skip]**: Strings committers can place inside a commit message to skip executing the corresponding actions workflow
denyskon marked this conversation as resolved.
Show resolved Hide resolved

`DEFAULT_ACTIONS_URL` indicates where the Gitea Actions runners should find the actions with relative path.
For example, `uses: actions/checkout@v3` means `https://github.com/actions/checkout@v3` since the value of `DEFAULT_ACTIONS_URL` is `github`.
Expand Down
8 changes: 4 additions & 4 deletions modules/setting/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ var (
ZombieTaskTimeout time.Duration `ini:"ZOMBIE_TASK_TIMEOUT"`
EndlessTaskTimeout time.Duration `ini:"ENDLESS_TASK_TIMEOUT"`
AbandonedJobTimeout time.Duration `ini:"ABANDONED_JOB_TIMEOUT"`
SkipRunStrings []string `ìni:"SKIP_RUN_STRINGS"`
SkipWorkflowStrings []string `ìni:"SKIP_WORKFLOW_STRINGS"`
}{
Enabled: true,
DefaultActionsURL: defaultActionsURLGitHub,
SkipRunStrings: []string{"[skip ci]", "[ci skip]", "[no ci]", "[skip actions]", "[actions skip]"},
Enabled: true,
DefaultActionsURL: defaultActionsURLGitHub,
SkipWorkflowStrings: []string{"[skip ci]", "[ci skip]", "[no ci]", "[skip actions]", "[actions skip]"},
}
)

Expand Down
8 changes: 4 additions & 4 deletions services/actions/notifier_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ func notify(ctx context.Context, input *notifyInput) error {
}

func skipWorkflowsForCommit(input *notifyInput, commit *git.Commit) bool {
// skip runs with a configured skip-ci string in commit message if the event is push or pull_request(_sync)
// skip workflow runs with a configured skip-ci string in commit message if the event is push or pull_request(_sync)
// https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs
skipRunEvents := []webhook_module.HookEventType{
skipWorkflowEvents := []webhook_module.HookEventType{
webhook_module.HookEventPush,
webhook_module.HookEventPullRequest,
webhook_module.HookEventPullRequestSync,
}
if slices.Contains(skipRunEvents, input.Event) {
for _, s := range setting.Actions.SkipRunStrings {
if slices.Contains(skipWorkflowEvents, input.Event) {
for _, s := range setting.Actions.SkipWorkflowStrings {
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
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/actions_trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func TestSkipCI(t *testing.T) {
ContentReader: strings.NewReader("bar"),
},
},
Message: fmt.Sprintf("%s add bar", setting.Actions.SkipRunStrings[0]),
Message: fmt.Sprintf("%s add bar", setting.Actions.SkipWorkflowStrings[0]),
OldBranch: "main",
NewBranch: "main",
Author: &files_service.IdentityOptions{
Expand Down