From fb043cc65a770e8051adbedbe412d169ddb23f27 Mon Sep 17 00:00:00 2001 From: lijie Date: Wed, 7 Feb 2024 17:50:46 +0800 Subject: [PATCH] feat: add tidb-ctl trigger (#962) # Why: - tidb-ctl only build for master branch --------- Signed-off-by: lijie --- .../triggers/triggers/kustomization.yaml | 2 + .../pingcap/tidb-ctl/git-create-tag.yaml | 27 +++++++++++++ .../triggers/pingcap/tidb-ctl/git-push.yaml | 27 +++++++++++++ .../triggers/pingcap/tidb-ctl/test.http | 40 +++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/git-create-tag.yaml create mode 100644 apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/git-push.yaml create mode 100644 apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/test.http diff --git a/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml b/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml index 742e112a6..627d84bf9 100644 --- a/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml +++ b/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml @@ -20,6 +20,8 @@ resources: - pingcap/ng-monitoring/git-push.yaml - pingcap/tidb-binlog/git-create-tag.yaml - pingcap/tidb-binlog/git-push.yaml + - pingcap/tidb-ctl/git-create-tag.yaml + - pingcap/tidb-ctl/git-push.yaml - pingcap/tidb-dashboard/fake-git-create-tag.yaml - pingcap/tidb-dashboard/fake-git-push.yaml - pingcap/tidb-dashboard/git-create-tag.yaml diff --git a/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/git-create-tag.yaml b/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/git-create-tag.yaml new file mode 100644 index 000000000..35d6ba4f9 --- /dev/null +++ b/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/git-create-tag.yaml @@ -0,0 +1,27 @@ +apiVersion: triggers.tekton.dev/v1beta1 +kind: Trigger +metadata: + name: tag-create-pingcap-tidb-ctl + labels: + type: github-tag-create + github-owner: pingcap + github-repo: tidb-ctl +spec: + interceptors: + - name: filter on repo owner and name + ref: + name: cel + params: + - name: filter + value: >- + body.repository.owner.login == 'pingcap' && body.repository.name == 'tidb-ctl' && body.ref.matches('^v[0-9]+[.][0-9]+[.][0-9]+') + bindings: + - ref: github-tag-create + - { name: component, value: $(body.repository.name) } + - { name: profile, value: release } + - { name: timeout, value: 1h } + - { name: source-ws-size, value: 10Gi } + - { name: builder-resources-memory, value: 4Gi } + - { name: builder-resources-cpu, value: "2" } + template: + ref: build-component-all-platforms diff --git a/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/git-push.yaml b/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/git-push.yaml new file mode 100644 index 000000000..1ef0751ce --- /dev/null +++ b/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/git-push.yaml @@ -0,0 +1,27 @@ +apiVersion: triggers.tekton.dev/v1beta1 +kind: Trigger +metadata: + name: git-push-pingcap-tidb-ctl + labels: + type: github-branch-push + github-owner: pingcap + github-repo: tidb-ctl +spec: + interceptors: + - name: filter on repo owner and name + ref: + name: cel + params: + - name: filter + value: >- + body.repository.owner.login == 'pingcap' && body.repository.name == 'tidb-ctl' && body.ref.matches('^refs/heads/(master)$') + bindings: + - ref: github-branch-push + - { name: component, value: $(body.repository.name) } + - { name: profile, value: release } + - { name: timeout, value: 1h } + - { name: source-ws-size, value: 10Gi } + - { name: builder-resources-memory, value: 4Gi } + - { name: builder-resources-cpu, value: "2" } + template: + ref: build-component-all-platforms diff --git a/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/test.http b/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/test.http new file mode 100644 index 000000000..35444e749 --- /dev/null +++ b/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb-ctl/test.http @@ -0,0 +1,40 @@ +## You should run it firstly: +## kubectl port-forward -n ee-cd svc/el-public 8080 + +### pingcap/tidb-ctl push on master branch +POST http://127.0.0.1:8080 HTTP/1.1 +Accept: */* +content-type: application/json +X-GitHub-Event: push + +{ + "ref": "refs/heads/master", + "before": "00000000000000000000000000000000000000000", + "after": "9c165585d38e16591d459f21c0c82b9518747aba", + "ref_type": "branch", + "repository": { + "name": "tidb-ctl", + "clone_url": "https://github.com/pingcap/tidb-ctl", + "owner": { + "login": "pingcap" + } + } +} + +### pingcap/tidb-ctl version tag created +POST http://127.0.0.1:8080 HTTP/1.1 +Accept: */* +content-type: application/json +X-GitHub-Event: create + +{ + "ref": "v7.5.0", + "ref_type": "tag", + "repository": { + "name": "tidb-ctl", + "clone_url": "https://github.com/pingcap/tidb-ctl.git", + "owner": { + "login": "pingcap" + } + } +}