Skip to content

Commit

Permalink
Fix GitHub example bindings
Browse files Browse the repository at this point in the history
The old bindings were for the GitHub push event while this EventListener is
configured for pull_request event types.  See:
https://developer.github.com/webhooks/event-payloads/#pull_request
  • Loading branch information
dibyom authored and tekton-robot committed Aug 10, 2020
1 parent 1779f66 commit b6d0aac
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 50 deletions.
49 changes: 48 additions & 1 deletion docs/eventlisteners.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,56 @@ spec:
- cel:
filter: "body.action in ['opened', 'synchronize', 'reopened']"
bindings:
- ref: github-binding
- ref: github-pr-binding
template:
name: github-template
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: github-pr-binding
spec:
params:
- name: gitrevision
value: $(body.pull_request.head.sha)
- name: gitrepositoryurl
value: $(body.repository.clone_url)
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
name: github-template
spec:
params:
- name: gitrevision
- name: gitrepositoryurl
resourcetemplates:
- apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
generateName: github-run-
spec:
taskSpec:
inputs:
resources:
- name: source
type: git
steps:
- image: ubuntu
script: |
#! /bin/bash
ls -al $(inputs.resources.source.path)
inputs:
resources:
- name: source
resourceSpec:
type: git
params:
- name: revision
value: $(tt.params.gitrevision)
- name: url
value: $(tt.params.gitrepositoryurl)
```


Expand Down
4 changes: 2 additions & 2 deletions examples/github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Creates an EventListener that listens for GitHub webhook events.
```bash
curl -v \
-H 'X-GitHub-Event: pull_request' \
-H 'X-Hub-Signature: sha1=13eaa0168f8d8efcdf5189ea75b782cf89809de6' \
-H 'X-Hub-Signature: sha1=ba0cdc263b3492a74b601d240c27efe81c4720cb' \
-H 'Content-Type: application/json' \
-d '{"action": "opened", "head_commit":{"id":"master"},"repository":{"url": "https://github.com/tektoncd/triggers"}}' \
-d '{"action": "opened", "pull_request":{"head":{"sha": "28911bbb5a3e2ea034daf1f6be0a822d50e31e73"}},"repository":{"clone_url": "https://github.com/tektoncd/triggers.git"}}' \
http://localhost:8080
```

Expand Down
49 changes: 48 additions & 1 deletion examples/github/github-eventlistener-interceptor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,53 @@ spec:
- cel:
filter: "body.action in ['opened', 'synchronize', 'reopened']"
bindings:
- ref: github-binding
- ref: github-pr-binding
template:
name: github-template
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: github-pr-binding
spec:
params:
- name: gitrevision
value: $(body.pull_request.head.sha)
- name: gitrepositoryurl
value: $(body.repository.clone_url)

---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
name: github-template
spec:
params:
- name: gitrevision
- name: gitrepositoryurl
resourcetemplates:
- apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
generateName: github-run-
spec:
taskSpec:
inputs:
resources:
- name: source
type: git
steps:
- image: ubuntu
script: |
#! /bin/bash
ls -al $(inputs.resources.source.path)
inputs:
resources:
- name: source
resourceSpec:
type: git
params:
- name: revision
value: $(tt.params.gitrevision)
- name: url
value: $(tt.params.gitrepositoryurl)
11 changes: 0 additions & 11 deletions examples/github/triggerbinding.yaml

This file was deleted.

35 changes: 0 additions & 35 deletions examples/github/triggertemplate.yaml

This file was deleted.

0 comments on commit b6d0aac

Please sign in to comment.