From 768545495b081c5aefe2e763e9587357eed641cf Mon Sep 17 00:00:00 2001 From: wuhuizuo Date: Thu, 29 Feb 2024 19:56:01 +0800 Subject: [PATCH] fix(pingcap/monitoring): no need human approve for the submodule updating PR (#2824) Signed-off-by: wuhuizuo Signed-off-by: wuhuizuo --- ...inc-enterprise-extensions-postsubmits.yaml | 4 ++ .../pingcap-ng-monitoring-postsubmits.yaml | 8 +++- scripts/plugins/update-submodule.ts | 37 ++++++++++++------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/prow-jobs/pingcap-inc-enterprise-extensions-postsubmits.yaml b/prow-jobs/pingcap-inc-enterprise-extensions-postsubmits.yaml index e0a82ddaa..12ba7ecd4 100644 --- a/prow-jobs/pingcap-inc-enterprise-extensions-postsubmits.yaml +++ b/prow-jobs/pingcap-inc-enterprise-extensions-postsubmits.yaml @@ -25,6 +25,8 @@ postsubmits: - --base_ref=$(PULL_BASE_REF) - --sub_ref=$(PULL_BASE_REF) - --path=pkg/extension/enterprise # new path + - --add_labels=lgtm + - --add_labels=skip-issue-check env: - name: GITHUB_API_TOKEN valueFrom: @@ -60,6 +62,8 @@ postsubmits: - --base_ref=$(PULL_BASE_REF) - --sub_ref=$(PULL_BASE_REF) - --path=extension/enterprise # old path + - --add_labels=lgtm + - --add_labels=skip-issue-check env: - name: GITHUB_API_TOKEN valueFrom: diff --git a/prow-jobs/pingcap-ng-monitoring-postsubmits.yaml b/prow-jobs/pingcap-ng-monitoring-postsubmits.yaml index 3718e63bc..191c60583 100644 --- a/prow-jobs/pingcap-ng-monitoring-postsubmits.yaml +++ b/prow-jobs/pingcap-ng-monitoring-postsubmits.yaml @@ -23,6 +23,9 @@ postsubmits: - --sub_repository=$(REPO_NAME) - --base_ref=$(PULL_BASE_REF) - --path=ng-monitoring + - --add_labels=lgtm + - --add_labels=approved + - --add_labels=skip-issue-check env: - name: GITHUB_API_TOKEN valueFrom: @@ -35,7 +38,7 @@ postsubmits: memory: 1Gi requests: cpu: "1" - memory: 1Gi + memory: 1Gi - name: update-submodule-release-branches decorate: true decoration_config: @@ -58,6 +61,9 @@ postsubmits: - --base_ref=$(PULL_BASE_REF) - --sub_ref=$(PULL_BASE_REF) - --path=ng-monitoring + - --add_labels=lgtm + - --add_labels=approved + - --add_labels=skip-issue-check env: - name: GITHUB_API_TOKEN valueFrom: diff --git a/scripts/plugins/update-submodule.ts b/scripts/plugins/update-submodule.ts index e2ec97cf4..b1e40510a 100644 --- a/scripts/plugins/update-submodule.ts +++ b/scripts/plugins/update-submodule.ts @@ -16,6 +16,7 @@ interface cliArgs { path: string; github_private_token: string; draft: boolean; + add_labels: string[]; // labels to add in post dealing. } function newCommitMsg(submodulePath: string) { @@ -86,8 +87,14 @@ async function createUpdateSubModulePR( ) { // Get target branch's git commit SHA. console.debug("-----"); - console.debug(owner, repository, subOwner, subRepository); - console.log(baseRef, subRef); + console.debug({ + owner, + repository, + subOwner, + subRepository, + baseRef, + subRef, + }); const { data } = await octokit.rest.git.getRef({ owner, @@ -174,6 +181,7 @@ async function postDealPR( owner: string, repo: string, prNumber: number, + toAddLabels: string[], ) { // add "/release-note-none" comment. await octokit.rest.issues.createComment({ @@ -183,17 +191,14 @@ async function postDealPR( body: "/release-note-none", }).catch((error: any) => console.error("Error creating comment:", error)); - // add "skip-issue-check", "lgtm" labels: - const toAddLabels = ["skip-issue-check", "lgtm"]; - if (repo.startsWith("docs")) { - toAddLabels.push("translation/no-need"); + if (toAddLabels) { + await octokit.rest.issues.addLabels({ + owner, + repo, + issue_number: prNumber, + labels: toAddLabels, + }).catch((error: any) => console.error("Error add labels:", error)); } - await octokit.rest.issues.addLabels({ - owner, - repo, - issue_number: prNumber, - labels: toAddLabels, - }).catch((error: any) => console.error("Error add labels:", error)); } // Ref: https://stackoverflow.com/questions/45789854/how-to-update-a-submodule-to-a-specified-commit-via-github-rest-api @@ -208,6 +213,7 @@ async function main(args: cliArgs) { path, github_private_token, draft, + add_labels: addLabels, } = args; // Create a new Octokit instance using the provided token const octokit = new Octokit({ auth: github_private_token }); @@ -239,6 +245,7 @@ async function main(args: cliArgs) { owner, repository, pullRequest.number, + addLabels, ); console.info( `✅ Post done for pull request: ${owner}/${repository}/${pullRequest.number} ...`, @@ -258,7 +265,9 @@ async function main(args: cliArgs) { * --path * --github_private_token * --draft, optional. + * --add_labels