Skip to content

Commit

Permalink
Add cel filter for pull request actions in github example
Browse files Browse the repository at this point in the history
The GitHub interceptor doesn't filter the actions for the `pull_request` event type, which means it will trigger when editing a pull requests' description and other similar actions.

This commit adds a CEL interceptor in order to filter the pull request actions and only trigger when a pull request is opened, synchronized, or reopened.
  • Loading branch information
ljupchokotev committed Jun 25, 2020
1 parent 9c45166 commit 75c88a6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/eventlisteners.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ spec:
secretKey: secretToken
eventTypes:
- pull_request
- cel:
filter: >-
body.action == 'opened' ||
body.action == 'synchronize' ||
body.action == 'reopened'
bindings:
- ref: github-binding
template:
Expand Down
2 changes: 1 addition & 1 deletion examples/github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Creates an EventListener that listens for GitHub webhook events.
-H 'X-GitHub-Event: pull_request' \
-H 'X-Hub-Signature: sha1=0835c8c5dc317870c4e48659df5f3c53213cd348' \
-H 'Content-Type: application/json' \
-d '{"head_commit":{"id":"master"},"repository":{"url": "https://github.com/tektoncd/triggers"}}' \
-d '{"action": "opened", "head_commit":{"id":"master"},"repository":{"url": "https://github.com/tektoncd/triggers"}}' \
http://localhost:8080
```

Expand Down
5 changes: 5 additions & 0 deletions examples/github/github-eventlistener-interceptor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ spec:
secretKey: secretToken
eventTypes:
- pull_request
- cel:
filter: >-
body.action == 'opened' ||
body.action == 'synchronize' ||
body.action == 'reopened'
bindings:
- ref: github-binding
template:
Expand Down

0 comments on commit 75c88a6

Please sign in to comment.