Skip to content

Commit

Permalink
feat(apps/prod/tekton/configs): add new flow to help ci on PRs
Browse files Browse the repository at this point in the history
Signed-off-by: wuhuizuo <wuhuizuo@126.com>
  • Loading branch information
wuhuizuo committed Oct 9, 2024
1 parent 54c640e commit 3615785
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 5 deletions.
26 changes: 26 additions & 0 deletions apps/prod/tekton/configs/tasks/ci/ci-helper-for-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: ci-helper-for-pr
spec:
description: >-
Create pull request to update version placeholder "README.md" to github repository branch.
params:
- name: owner
description: repo owner
- name: repo
description: repo short name
- name: number
description: pull request number
type: integer
steps:
- name: create-pull-request
image: denoland/deno:1.45.5
script: |
echo "owner: $(params.owner)"
echo "repo: $(params.repo)"
echo "number: $(params.number)"
workspaces:
- name: github
description: Must includes a key `token`
mountPath: /etc/github
1 change: 1 addition & 0 deletions apps/prod/tekton/configs/tasks/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ resources:
- aws-cli.yaml # from and hacked: https://hub.tekton.dev/tekton/task/aws-cli
- boskos-acquire.yaml # from: https://hub.tekton.dev/tekton/task/boskos-acquire
- boskos-release.yaml # from: https://hub.tekton.dev/tekton/task/boskos-release
- ci/ci-helper-for-pr.yaml
- crane-copy.yaml # crane copy task
- echo.yaml ##### an example task.
- gen-build-binaries-scripts.yaml
Expand Down
10 changes: 8 additions & 2 deletions apps/prod/tekton/configs/triggers/bindings/github-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ spec:
# value: $(body.pull_request.title)
# - name: pr-body
# value: $(body.pull_request.body)
# - name: pr-user
# value: $(body.pull_request.user.login)
- name: pr-author
value: $(body.pull_request.user.login)
- name: pr-owner
value: $(body.repository.owner.login)
- name: pr-repo
value: $(body.repository.name)
- name: pr-full-repo
value: $(body.repository.full_name)
# - name: pr-head-owner
# value: $(body.pull_request.head.user.login)
# - name: pr-head-repo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
name: cel
params:
- name: filter
value: body.action in ['opened', 'synchronize', 'reopened']
value: body.action in ['opened', 'synchronize', 'reopened', 'labeled']
triggerSelector:
namespaceSelector:
matchNames:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate
metadata:
name: ci-helper-for-pr
spec:
params:
- name: pr-owner
- name: pr-repo
- name: pr-number
type: integer
resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: ci-helper-for-pr-
spec:
params:
- name: owner
value: $(tt.params.pr-owner)
- name: repo
value: $(tt.params.repo)
- name: number
value: $(tt.params.pr-number)
taskRef:
name: ci-helper-for-pr
workspaces:
- name: github
secret:
secretName: github
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ resources:
- _/build-component-all-platforms.yaml
- _/build-component-single-platform.yaml
- _/build-component.yaml
- _/ci-helper-for-pr.yaml
- _/image-push.yaml
- _/push-oci-artifact-to-tiup.yaml
- pingcap/bump-placeholder-version-in-readme.yaml
- pingcap/sync-owners-for-hotfix-branch.yaml
- pingcap/tidb/update-gomod-for-hotfix-branch.yaml
- tikv/tikv/bump-tikv-cargo-pkg-version.yaml
- tikv/tikv/bump-tikv-cargo-pkg-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: Trigger
metadata:
name: pr-labeled-with-needs-ok-to-test
labels:
type: github-pr
github-owner: pingcap
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 ['needs-ok-to-test']
&&
body.pull_request.user.login in ['wuhuizuo', 'purlind']
&&
body.repository.owner.login == 'pingcap'
bindings:
- ref: github-pr
template:
ref: ci-helper-for-pr
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resources:
- _/fake-github/fake-github-pr.yaml
- _/fake-github/fake-github-tag-create.yaml
- _/git-push-on-fips-branches.yaml
- _/github-pr-labeled.yaml
- _/harbor/artifact-push-on-harbor.yaml
- _/harbor/image-push-on-harbor.yaml
- PingCAP-QE/artifacts/git-push.yaml
Expand Down Expand Up @@ -34,4 +35,4 @@ resources:
- tikv/pd/git-push.yaml
- tikv/tikv/git-create-branch.yaml
- tikv/tikv/git-create-tag.yaml
- tikv/tikv/git-push.yaml
- tikv/tikv/git-push.yaml

0 comments on commit 3615785

Please sign in to comment.