From e11361f51367b850ede8539a8faac83c7477ba80 Mon Sep 17 00:00:00 2001 From: Hao Li <18546749+haofrank@users.noreply.github.com> Date: Tue, 5 Dec 2023 02:20:12 -0500 Subject: [PATCH] add trigger configs --- .tekton/events/event_listener.yaml | 25 +++++++++++++++++++ .tekton/events/route.yaml | 15 +++++++++++ .tekton/events/trigger_binding.yaml | 17 +++++++++++++ .tekton/events/trigger_template.yaml | 37 ++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 .tekton/events/event_listener.yaml create mode 100644 .tekton/events/route.yaml create mode 100644 .tekton/events/trigger_binding.yaml create mode 100644 .tekton/events/trigger_template.yaml diff --git a/.tekton/events/event_listener.yaml b/.tekton/events/event_listener.yaml new file mode 100644 index 0000000..c5c2bb7 --- /dev/null +++ b/.tekton/events/event_listener.yaml @@ -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 \ No newline at end of file diff --git a/.tekton/events/route.yaml b/.tekton/events/route.yaml new file mode 100644 index 0000000..0062289 --- /dev/null +++ b/.tekton/events/route.yaml @@ -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 diff --git a/.tekton/events/trigger_binding.yaml b/.tekton/events/trigger_binding.yaml new file mode 100644 index 0000000..99021a4 --- /dev/null +++ b/.tekton/events/trigger_binding.yaml @@ -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) + diff --git a/.tekton/events/trigger_template.yaml b/.tekton/events/trigger_template.yaml new file mode 100644 index 0000000..4059913 --- /dev/null +++ b/.tekton/events/trigger_template.yaml @@ -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