From 0383987fb1cccb496e83eaa0ac7cb7c2c9a362cc Mon Sep 17 00:00:00 2001 From: wuhuizuo <wuhuizuo@126.com> Date: Fri, 6 Dec 2024 03:55:36 +0000 Subject: [PATCH] feat(apps/prod/tekton/configs/triggers): add github-pr-labeled-with-lgtm trigger Signed-off-by: wuhuizuo <wuhuizuo@126.com> --- .../_/github-pr-labeled-with-lgtm.yaml | 74 +++++++++++++++++++ ...hub-pr-labeled-with-needs-ok-to-test.yaml} | 0 .../triggers/triggers/kustomization.yaml | 3 +- 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 apps/prod/tekton/configs/triggers/triggers/_/github-pr-labeled-with-lgtm.yaml rename apps/prod/tekton/configs/triggers/triggers/_/{github-pr-labeled.yaml => github-pr-labeled-with-needs-ok-to-test.yaml} (100%) diff --git a/apps/prod/tekton/configs/triggers/triggers/_/github-pr-labeled-with-lgtm.yaml b/apps/prod/tekton/configs/triggers/triggers/_/github-pr-labeled-with-lgtm.yaml new file mode 100644 index 000000000..141cf3b66 --- /dev/null +++ b/apps/prod/tekton/configs/triggers/triggers/_/github-pr-labeled-with-lgtm.yaml @@ -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 diff --git a/apps/prod/tekton/configs/triggers/triggers/_/github-pr-labeled.yaml b/apps/prod/tekton/configs/triggers/triggers/_/github-pr-labeled-with-needs-ok-to-test.yaml similarity index 100% rename from apps/prod/tekton/configs/triggers/triggers/_/github-pr-labeled.yaml rename to apps/prod/tekton/configs/triggers/triggers/_/github-pr-labeled-with-needs-ok-to-test.yaml diff --git a/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml b/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml index 5df42b4bc..eda8c9b44 100644 --- a/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml +++ b/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml @@ -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