Skip to content

Commit

Permalink
Merge pull request #74 from CSCI-GA-2820-FA23-001/webhook
Browse files Browse the repository at this point in the history
add trigger and webhook
  • Loading branch information
haofrank authored Dec 7, 2023
2 parents 379de76 + e11361f commit 7711642
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .tekton/events/event_listener.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: cd-listener
spec:
serviceAccountName: pipeline
triggers:
- name: github-release
interceptors:
- ref:
name: cel
params:
- name: filter
value: "body.action == 'published'"
- ref:
name: "github"
kind: ClusterInterceptor
apiVersion: triggers.tekton.dev
params:
- name: "eventTypes"
value: ["release"]
bindings:
- ref: cd-binding
template:
ref: cd-template
15 changes: 15 additions & 0 deletions .tekton/events/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: cd-pipeline
labels:
app.kubernetes.io/managed-by: EventListener
app.kubernetes.io/part-of: Triggers
eventlistener: cd-listener
spec:
to:
kind: Service
name: el-cd-listener
tls: {}
port:
targetPort: http-listener
17 changes: 17 additions & 0 deletions .tekton/events/trigger_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerBinding
metadata:
name: cd-binding
spec:
params:
- name: git-repo-url
value: $(body.repository.clone_url)
- name: git-repo-name
value: $(body.repository.name)
- name: git-revision
# use release tag name
value: $(body.release.tag_name)
- name: git-ref
# use release tag name
value: $(body.release.tag_name)

37 changes: 37 additions & 0 deletions .tekton/events/trigger_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate
metadata:
name: cd-template
spec:
params:
- name: git-repo-url
description: The git repository url
- name: git-revision
description: The git revision
- name: git-repo-name
description: The name of the deployment to be created / patched
- name: git-ref
description: The name of git branch or tag

resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: cd-pipeline-$(tt.params.git-repo-name)-
spec:
serviceAccountName: pipeline
pipelineRef:
name: cd-pipeline
params:
- name: APP_NAME
value: $(tt.params.git-repo-name)
- name: GIT_REPO
value: $(tt.params.git-repo-url)
- name: GIT_REF
value: $(tt.params.git-ref)
- name: IMAGE_NAME
value: image-registry.openshift-image-registry.svc:5000/$(context.pipelineRun.namespace)/$(tt.params.git-repo-name):$(tt.params.git-revision)
workspaces:
- name: pipeline-workspace
persistentVolumeClaim:
claimName: pipeline-pvc

0 comments on commit 7711642

Please sign in to comment.