forked from tektoncd/triggers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored examples and added github example with README
- Loading branch information
1 parent
b8ca4f0
commit 61a2e7b
Showing
20 changed files
with
235 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: tekton-triggers-cron-binding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: tekton-triggers-cron-sa | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: tekton-triggers-cron-minimal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: tekton-triggers-cron-minimal | ||
rules: | ||
# Permissions for every EventListener deployment to function | ||
- apiGroups: ["triggers.tekton.dev"] | ||
resources: ["eventlisteners", "triggerbindings", "triggertemplates"] | ||
verbs: ["get"] | ||
- apiGroups: [""] | ||
# secrets are only needed for Github/Gitlab interceptors, serviceaccounts only for per trigger authorization | ||
resources: ["configmaps", "secrets", "serviceaccounts"] | ||
verbs: ["get", "list", "watch"] | ||
# Permissions to create resources in associated TriggerTemplates | ||
- apiGroups: ["tekton.dev"] | ||
resources: ["pipelineruns", "pipelineresources", "taskruns"] | ||
verbs: ["create"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: githubsecret | ||
name: cron-secret | ||
type: Opaque | ||
stringData: | ||
secretToken: "1234567" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: tekton-triggers-cron-sa | ||
secrets: | ||
- name: cron-secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
## GitHub EventListener | ||
|
||
Creates an EventListener that listens for GitHub webhook events. | ||
|
||
### Try it out locally: | ||
|
||
1. To create the GitHub trigger and all related resources, run: | ||
|
||
```bash | ||
kubectl apply -f examples/github/ | ||
``` | ||
|
||
1. Port forward: | ||
|
||
```bash | ||
kubectl port-forward \ | ||
"$(kubectl get pod --selector=eventlistener=github-listener-interceptor -oname)" \ | ||
8080 | ||
``` | ||
|
||
**Note**: Instead of port forwarding, you can set the | ||
[`serviceType`](https://github.com/tektoncd/triggers/blob/master/docs/eventlisteners.md#serviceType) | ||
to `LoadBalancer` to expose the EventListener with a public IP. | ||
|
||
1. Test by sending the sample payload. | ||
|
||
```bash | ||
curl -v \ | ||
-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"}}' \ | ||
http://localhost:8080 | ||
``` | ||
|
||
The response status code should be `201 Created` | ||
|
||
[`HMAC`](https://www.freeformatter.com/hmac-generator.html) tool used to create X-Hub-Signature. | ||
|
||
In [`HMAC`](https://www.freeformatter.com/hmac-generator.html) `string` is the *body payload* and `secretKey` is the *given secretToken*. | ||
|
||
1. You should see a new TaskRun that got created: | ||
|
||
```bash | ||
kubectl get taskruns | grep github-run- | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: tekton-triggers-github-sa | ||
secrets: | ||
- name: github-secret | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: tekton-triggers-github-binding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: tekton-triggers-github-sa | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: tekton-triggers-github-minimal | ||
--- | ||
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: tekton-triggers-github-minimal | ||
rules: | ||
# Permissions for every EventListener deployment to function | ||
- apiGroups: ["triggers.tekton.dev"] | ||
resources: ["eventlisteners", "triggerbindings", "triggertemplates"] | ||
verbs: ["get"] | ||
- apiGroups: [""] | ||
# secrets are only needed for Github/Gitlab interceptors, serviceaccounts only for per trigger authorization | ||
resources: ["configmaps", "secrets", "serviceaccounts"] | ||
verbs: ["get", "list", "watch"] | ||
# Permissions to create resources in associated TriggerTemplates | ||
- apiGroups: ["tekton.dev"] | ||
resources: ["pipelineruns", "pipelineresources", "taskruns"] | ||
verbs: ["create"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: github-secret | ||
type: Opaque | ||
stringData: | ||
secretToken: "1234567" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
apiVersion: triggers.tekton.dev/v1alpha1 | ||
kind: TriggerBinding | ||
metadata: | ||
name: github-binding | ||
spec: | ||
params: | ||
- name: gitrevision | ||
value: $(body.head_commit.id) | ||
- name: gitrepositoryurl | ||
value: $(body.repository.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
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: $(params.gitrevision) | ||
- name: url | ||
value: $(params.gitrepositoryurl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: tekton-triggers-gitlab-binding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: tekton-triggers-gitlab-sa | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: tekton-triggers-gitlab-minimal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: tekton-triggers-gitlab-minimal | ||
rules: | ||
# Permissions for every EventListener deployment to function | ||
- apiGroups: ["triggers.tekton.dev"] | ||
resources: ["eventlisteners", "triggerbindings", "triggertemplates"] | ||
verbs: ["get"] | ||
- apiGroups: [""] | ||
# secrets are only needed for Github/Gitlab interceptors, serviceaccounts only for per trigger authorization | ||
resources: ["configmaps", "secrets", "serviceaccounts"] | ||
verbs: ["get", "list", "watch"] | ||
# Permissions to create resources in associated TriggerTemplates | ||
- apiGroups: ["tekton.dev"] | ||
resources: ["pipelineruns", "pipelineresources", "taskruns"] | ||
verbs: ["create"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: gitlab-secret | ||
type: Opaque | ||
stringData: | ||
secretToken: "1234567" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: tekton-triggers-gitlab-sa | ||
secrets: | ||
- name: gitlab-secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: githubsecret | ||
name: tekton-triggers-example-secret | ||
type: Opaque | ||
stringData: | ||
secretToken: "1234567" |
Oops, something went wrong.