Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(apps/prod/tekton/configs/triggers): add github-pr-labeled-with-lgtm trigger #1367

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: Trigger
metadata:
name: pr-to-feature-branches-labeled-with-lgtm
labels:
type: github-pr
spec:
interceptors:
- name: filter on repo owner and name and tags
ref: { name: cel }
params:
- name: filter
value: >-
body.action == 'labeled'
&&
body.label.name in ['lgtm']
&&
body.repository.full_name in ['pingcap/tidb']
&&
body.pull_request.base.ref in ['feature/release-8.5-oracle-func-impl']
bindings:
- ref: github-pr
template:
spec:
params:
- name: pr-owner
- name: pr-repo
- name: pr-number
resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: auto-add-approved-label-to-pr-on-special-branch-
spec:
params:
- name: owner
value: $(tt.params.pr-owner)
- name: repo
value: $(tt.params.pr-repo)
- name: number
value: $(tt.params.pr-number)
taskSpec:
description: CI helper for contribution pull requests
params:
- name: owner
description: repo owner
- name: repo
description: repo short name
- name: number
description: pull request number
steps:
- name: create-pull-request
image: bitnami/git:2.43.0
script: |
#!/usr/bin/env bash
set -exo pipefail

# install `gh` tool
type -p curl >/dev/null || ( apt update && apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt update \
&& apt install gh -y

gh auth login --with-token < $(workspaces.github.path)/token
gh pr edit --add-label approved https://github.com/$(params.owner)/$(params.repo)/pull/$(params.number)
workspaces:
- name: github
description: Must includes a key `token`
workspaces:
- name: github
secret:
secretName: github
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ resources:
- _/fake-github/fake-github-pr.yaml
- _/fake-github/fake-github-tag-create.yaml
- _/git-push-on-fips-branches.yaml
- _/github-pr-labeled.yaml
- _/github-pr-labeled-with-lgtm.yaml
- _/github-pr-labeled-with-needs-ok-to-test.yaml
- _/harbor/artifact-push-on-harbor.yaml
- _/harbor/image-push-on-harbor.yaml
- PingCAP-QE/artifacts/git-push.yaml
Expand Down
Loading