github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/.tekton/ci-build/github-eventlistener.yaml (about) 1 # (c) Copyright IBM Corp. 2024 2 3 apiVersion: triggers.tekton.dev/v1beta1 4 kind: TriggerTemplate 5 metadata: 6 name: github-pipeline-template 7 spec: 8 params: 9 - description: The git branch name 10 name: git-branch 11 - description: The git branch name shortened and converted to RFC 1123 subdomain names 12 name: git-branch-normalized 13 - description: The full sha of the git commit 14 name: git-commit-sha 15 - description: The short 7 digit sha of the git commit 16 name: git-commit-short-sha 17 resourcetemplates: 18 - apiVersion: tekton.dev/v1 19 kind: PipelineRun 20 metadata: 21 # After variable resolution, this has to be maximum 63 character long, 22 # lower case, RFC 1123 subdomain name. The regex used for validation is 23 # '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*' 24 name: $(tt.params.git-branch-normalized)-go22-$(tt.params.git-commit-short-sha) 25 spec: 26 params: 27 - name: revision 28 value: $(tt.params.git-branch) 29 - name: git-commit-sha 30 value: $(tt.params.git-commit-sha) 31 - name: go-version 32 value: "1.22" 33 - name: excludeDirs 34 value: "" 35 pipelineRef: 36 name: go-tracer-ci-pipeline 37 workspaces: 38 - name: go-tracer-ci-pipeline-pvc 39 volumeClaimTemplate: 40 spec: 41 accessModes: 42 - ReadWriteOnce 43 resources: 44 requests: 45 storage: 1Gi 46 - name: cache-pvc 47 persistentVolumeClaim: 48 claimName: cache-pvc 49 50 - apiVersion: tekton.dev/v1 51 kind: PipelineRun 52 metadata: 53 name: $(tt.params.git-branch-normalized)-go21-$(tt.params.git-commit-short-sha) 54 spec: 55 params: 56 - name: revision 57 value: $(tt.params.git-branch) 58 - name: git-commit-sha 59 value: $(tt.params.git-commit-sha) 60 - name: go-version 61 value: "1.21" 62 - name: excludeDirs 63 value: "./instrumentation/instacosmos" 64 pipelineRef: 65 name: go-tracer-ci-pipeline 66 workspaces: 67 - name: go-tracer-ci-pipeline-pvc 68 volumeClaimTemplate: 69 spec: 70 accessModes: 71 - ReadWriteOnce 72 resources: 73 requests: 74 storage: 1Gi 75 - name: cache-pvc 76 persistentVolumeClaim: 77 claimName: cache-pvc 78 79 --- 80 apiVersion: triggers.tekton.dev/v1beta1 81 kind: TriggerBinding 82 metadata: 83 name: github-pr-binding 84 spec: 85 params: 86 - name: git-branch 87 value: $(body.pull_request.head.ref) 88 - name: git-branch-normalized 89 value: $(extensions.git_branch_normalized) 90 - name: git-commit-sha 91 value: $(body.pull_request.head.sha) 92 - name: git-commit-short-sha 93 value: $(extensions.truncated_sha) 94 95 --- 96 apiVersion: triggers.tekton.dev/v1beta1 97 kind: TriggerBinding 98 metadata: 99 name: github-push-binding 100 spec: 101 params: 102 - name: git-branch 103 value: $(extensions.git_branch) 104 - name: git-branch-normalized 105 value: $(extensions.git_branch_normalized) 106 - name: git-commit-sha 107 value: $(body.head_commit.id) 108 - name: git-commit-short-sha 109 value: $(extensions.truncated_sha) 110 --- 111 apiVersion: triggers.tekton.dev/v1beta1 112 kind: EventListener 113 metadata: 114 name: github-pr-eventlistener 115 spec: 116 serviceAccountName: tekton-triggers-eventlistener-serviceaccount 117 triggers: 118 - name: github-pr-trigger 119 interceptors: 120 - name: receive-github-event 121 ref: 122 name: "github" 123 params: 124 - name: "secretRef" 125 value: 126 secretName: github-interceptor-secret 127 secretKey: secretToken 128 - name: "eventTypes" 129 value: ["pull_request"] 130 - name: filter-and-modify 131 ref: 132 name: "cel" 133 params: 134 - name: "filter" 135 # We should not trigger on 'closed', 'assigned', 'unassigned', 'converted_to_draft' 136 value: "body.action in ['opened', 'synchronize', 'reopened', 'labeled', 'unlabeled'] && body.pull_request.labels.exists(label, label.name == 'tekton_ci')" 137 - name: "overlays" 138 value: 139 - key: truncated_sha 140 expression: "body.pull_request.head.sha.truncate(7)" 141 - key: git_branch_normalized 142 # The git branch name shortened and converted to RFC 1123 subdomain names 143 expression: 'body.pull_request.head.ref.truncate(32).lowerAscii().translate("_", "-").translate("/", "-").translate("\\.", "-")' 144 bindings: 145 - ref: github-pr-binding 146 template: 147 ref: github-pipeline-template 148 --- 149 apiVersion: triggers.tekton.dev/v1beta1 150 kind: EventListener 151 metadata: 152 name: github-push-eventlistener 153 spec: 154 serviceAccountName: tekton-triggers-eventlistener-serviceaccount 155 triggers: 156 - name: github-push-trigger 157 interceptors: 158 - name: receive-github-push-event 159 ref: 160 name: "github" 161 params: 162 - name: "secretRef" 163 value: 164 secretName: github-interceptor-secret 165 secretKey: secretToken 166 - name: "eventTypes" 167 value: ["push"] 168 - name: filter-and-modify 169 ref: 170 name: "cel" 171 params: 172 - name: "filter" 173 # We should trigger on push to main branch only 174 value: "body.ref in ['refs/heads/main']" 175 - name: "overlays" 176 value: 177 - key: truncated_sha 178 expression: "body.head_commit.id.truncate(7)" 179 - key: git_branch 180 expression: 'body.ref.translate("refs/heads/", "")' 181 - key: git_branch_normalized 182 # The git branch name shortened and converted to RFC 1123 subdomain names 183 expression: 'body.ref.translate("refs/heads/", "").truncate(32).lowerAscii().translate("_", "-").translate("/", "-")' 184 bindings: 185 - ref: github-push-binding 186 template: 187 ref: github-pipeline-template