Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions cmd/server/openapi/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5484,6 +5484,7 @@ const docTemplate = `{
"push",
"pull_request",
"pull_request_closed",
"pull_request_edited",
"tag",
"release",
"deployment",
Expand All @@ -5494,6 +5495,7 @@ const docTemplate = `{
"EventPush",
"EventPull",
"EventPullClosed",
"EventPullEdited",
"EventTag",
"EventRelease",
"EventDeploy",
Expand Down
1 change: 1 addition & 0 deletions docs/docs/20-usage/20-workflow-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ The available events are:
- `push`: triggered when a commit is pushed to a branch.
- `pull_request`: triggered when a pull request is opened or a new commit is pushed to it.
- `pull_request_closed`: triggered when a pull request is closed or merged.
- `pull_request_edited`: triggered when a pull request is edited (the PR title or body).
- `tag`: triggered when a tag is pushed.
- `release`: triggered when a release, pre-release or draft is created. (You can apply further filters using [evaluate](#evaluate) with [environment variables](./50-environment.md#built-in-environment-variables).)
- `deployment`: triggered when a deployment is created in the repository. (This event can be triggered from Woodpecker directly. GitHub also supports webhook triggers.)
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/20-usage/50-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ This is the reference list of all environment variables available to your pipeli
| `CI_COMMIT_REF` | commit ref | `refs/heads/main` |
| `CI_COMMIT_REFSPEC` | commit ref spec | `issue-branch:main` |
| `CI_COMMIT_BRANCH` | commit branch (equals target branch for pull requests) | `main` |
| `CI_COMMIT_SOURCE_BRANCH` | commit source branch (set only for `pull_request` and `pull_request_closed` events) | `issue-branch` |
| `CI_COMMIT_TARGET_BRANCH` | commit target branch (set only for `pull_request` and `pull_request_closed` events) | `main` |
| `CI_COMMIT_SOURCE_BRANCH` | commit source branch (set only for pull request events) | `issue-branch` |
| `CI_COMMIT_TARGET_BRANCH` | commit target branch (set only for pull request events) | `main` |
| `CI_COMMIT_TAG` | commit tag name (empty if event is not `tag`) | `v1.10.3` |
| `CI_COMMIT_PULL_REQUEST` | commit pull request number (set only for `pull_request` and `pull_request_closed` events) | `1` |
| `CI_COMMIT_PULL_REQUEST_LABELS` | labels assigned to pull request (set only for `pull_request` and `pull_request_closed` events) | `server` |
| `CI_COMMIT_PULL_REQUEST` | commit pull request number (set only for pull request events) | `1` |
| `CI_COMMIT_PULL_REQUEST_LABELS` | labels assigned to pull request (set only for pull request events) | `server` |
| `CI_COMMIT_MESSAGE` | commit message | `Initial commit` |
| `CI_COMMIT_AUTHOR` | commit author username | `john-doe` |
| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | `john-doe@example.com` |
Expand Down Expand Up @@ -102,8 +102,8 @@ This is the reference list of all environment variables available to your pipeli
| `CI_PREV_COMMIT_REF` | previous commit ref | `refs/heads/main` |
| `CI_PREV_COMMIT_REFSPEC` | previous commit ref spec | `issue-branch:main` |
| `CI_PREV_COMMIT_BRANCH` | previous commit branch | `main` |
| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch (set only for `pull_request` and `pull_request_closed` events) | `issue-branch` |
| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch (set only for `pull_request` and `pull_request_closed` events) | `main` |
| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch (set only for pull request events) | `issue-branch` |
| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch (set only for pull request events) | `main` |
| `CI_PREV_COMMIT_URL` | previous commit link in forge | `https://git.example.com/john-doe/my-repo/commit/15784117e4e103f36cba75a9e29da48046eb82c4` |
| `CI_PREV_COMMIT_MESSAGE` | previous commit message | `test` |
| `CI_PREV_COMMIT_AUTHOR` | previous commit author username | `john-doe` |
Expand Down
1 change: 1 addition & 0 deletions pipeline/frontend/metadata/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
EventPush = "push"
EventPull = "pull_request"
EventPullClosed = "pull_request_closed"
EventPullEdited = "pull_request_edited"
EventTag = "tag"
EventRelease = "release"
EventDeploy = "deployment"
Expand Down
4 changes: 2 additions & 2 deletions pipeline/frontend/metadata/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
if pipeline.Event == EventRelease {
setNonEmptyEnvVar(params, "CI_COMMIT_PRERELEASE", strconv.FormatBool(pipeline.Commit.IsPrerelease))
}
if pipeline.Event == EventPull || pipeline.Event == EventPullClosed {
if pipeline.Event == EventPull || pipeline.Event == EventPullClosed || pipeline.Event == EventPullEdited {

Check warning on line 103 in pipeline/frontend/metadata/environment.go

View check run for this annotation

Codecov / codecov/patch

pipeline/frontend/metadata/environment.go#L103

Added line #L103 was not covered by tests
sourceBranch, targetBranch := getSourceTargetBranches(commit.Refspec)
setNonEmptyEnvVar(params, "CI_COMMIT_SOURCE_BRANCH", sourceBranch)
setNonEmptyEnvVar(params, "CI_COMMIT_TARGET_BRANCH", targetBranch)
Expand Down Expand Up @@ -144,7 +144,7 @@
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR", prevCommit.Author.Name)
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR_EMAIL", prevCommit.Author.Email)
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR_AVATAR", prevCommit.Author.Avatar)
if prevPipeline.Event == EventPull || prevPipeline.Event == EventPullClosed {
if prevPipeline.Event == EventPull || prevPipeline.Event == EventPullClosed || prevPipeline.Event == EventPullEdited {

Check warning on line 147 in pipeline/frontend/metadata/environment.go

View check run for this annotation

Codecov / codecov/patch

pipeline/frontend/metadata/environment.go#L147

Added line #L147 was not covered by tests
prevSourceBranch, prevTargetBranch := getSourceTargetBranches(prevCommit.Refspec)
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_SOURCE_BRANCH", prevSourceBranch)
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_TARGET_BRANCH", prevTargetBranch)
Expand Down
12 changes: 3 additions & 9 deletions pipeline/frontend/yaml/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package compiler
import (
"fmt"
"path"
"slices"

backend_types "go.woodpecker-ci.org/woodpecker/v3/pipeline/backend/types"
"go.woodpecker-ci.org/woodpecker/v3/pipeline/frontend/metadata"
Expand Down Expand Up @@ -68,17 +69,10 @@ func (s *Secret) Match(event string) bool {
return true
}
// treat all pull events the same way
if event == "pull_request_closed" {
if event == "pull_request_closed" || event == "pull_request_edited" {
event = "pull_request"
}
// one match is enough
for _, e := range s.Events {
if e == event {
return true
}
}
// a filter is set but the webhook did not match it
return false
return slices.Contains(s.Events, event)
}

// Compiler compiles the yaml.
Expand Down
6 changes: 6 additions & 0 deletions pipeline/frontend/yaml/compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ func TestSecretMatch(t *testing.T) {
event: "pull_request_closed",
match: true,
},
{
name: "pull edited should match pull",
secret: Secret{Events: []string{"pull_request"}},
event: "pull_request_edited",
match: true,
},
}

for _, tc := range tcl {
Expand Down
2 changes: 1 addition & 1 deletion pipeline/frontend/yaml/constraint/constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (c *Constraint) Match(m metadata.Metadata, global bool, env map[string]stri
c.Instance.Match(m.Sys.Host)

// changed files filter apply only for pull-request and push events
if m.Curr.Event == metadata.EventPull || m.Curr.Event == metadata.EventPullClosed || m.Curr.Event == metadata.EventPush {
if m.Curr.Event == metadata.EventPull || m.Curr.Event == metadata.EventPullClosed || m.Curr.Event == metadata.EventPullEdited || m.Curr.Event == metadata.EventPush {
match = match && c.Path.Match(m.Curr.Commit.ChangedFiles, m.Curr.Commit.Message)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ when:
- event:
exclude: pull_request_closed
evaluate: 'CI_COMMIT_AUTHOR == "woodpecker-ci"'
- event:
exclude: pull_request_edited
evaluate: 'CI_COMMIT_AUTHOR == "woodpecker-ci"'

steps:
echo:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ steps:
- push
- pull_request
- pull_request_closed
- pull_request_edited
- tag
- deployment
- release
Expand Down
12 changes: 11 additions & 1 deletion pipeline/frontend/yaml/linter/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,17 @@
}
},
"event_enum": {
"enum": ["push", "pull_request", "pull_request_closed", "tag", "deployment", "cron", "manual", "release"]
"enum": [
"push",
"pull_request",
"pull_request_closed",
"pull_request_edited",
"tag",
"deployment",
"cron",
"manual",
"release"
]
},
"event_constraint_list": {
"oneOf": [
Expand Down
Loading