From 11db0a16982791b59c3d32c7b98bef018dd02c3c Mon Sep 17 00:00:00 2001 From: huangzhangshu Date: Wed, 23 Jul 2025 18:47:43 +0800 Subject: [PATCH 1/2] chore: check pr run --- .github/workflows/cicd-pull-request.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cicd-pull-request.yml b/.github/workflows/cicd-pull-request.yml index fbef462185e..057812adfca 100644 --- a/.github/workflows/cicd-pull-request.yml +++ b/.github/workflows/cicd-pull-request.yml @@ -9,16 +9,18 @@ on: env: GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} BASE_BRANCH: origin/main GO_VERSION: "1.23" jobs: trigger-mode: name: trigger mode - if: github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'pre-approve') + if: github.event.action == 'labeled' runs-on: ubuntu-latest outputs: trigger-mode: ${{ steps.get_trigger_mode.outputs.trigger_mode }} + trigger-run: ${{ steps.get_trigger_run.outputs.trigger_run }} git-commit: ${{ steps.get_git_info.outputs.git_commit }} git-version: ${{ steps.get_git_info.outputs.git_version }} steps: @@ -33,7 +35,21 @@ jobs: fetch-depth: 0 repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: check run + id: get_trigger_run + run: | + TRIGGER_RUN="false" + PR_NUMBER="${{ github.event.pull_request.number }}" + GITHUB_REPO="${{ github.repository }}" + pr_view_labels=$(gh pr view ${PR_NUMBER} --repo ${GITHUB_REPO} --json "labels") + pr_labels=$(echo "${pr_view_labels}" | jq -r '.labels[].name') + if [[ "${pr_labels}" == *"approved"* || "${pr_labels}" == *"pre-approve"* ]]; then + TRIGGER_RUN="true" + fi + echo "trigger_run="$TRIGGER_RUN >> $GITHUB_OUTPUT + - name: Get trigger mode + if: ${{ steps.get_trigger_run.outputs.trigger_run == 'true' }} id: get_trigger_mode env: HEAD_REF: ${{ github.event.pull_request.head.ref }} @@ -167,7 +183,7 @@ jobs: pr-check: name: make test needs: [ trigger-mode, pr-pre-check, check-image, check-tools-image, check-dataprotection-image, check-helm ] - if: ${{ github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'pre-approve') && always() }} + if: ${{ github.event.action == 'labeled' && needs.trigger-mode.outputs.trigger-run == 'true' && always() }} runs-on: ubuntu-latest steps: - name: pr pre check From e4896ced5d8f37641fac0e57f0fdb7e61007b936 Mon Sep 17 00:00:00 2001 From: huangzhangshu Date: Wed, 23 Jul 2025 19:07:26 +0800 Subject: [PATCH 2/2] chore: print labels --- .github/workflows/cicd-pull-request.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cicd-pull-request.yml b/.github/workflows/cicd-pull-request.yml index 057812adfca..ff41ae1840c 100644 --- a/.github/workflows/cicd-pull-request.yml +++ b/.github/workflows/cicd-pull-request.yml @@ -43,6 +43,7 @@ jobs: GITHUB_REPO="${{ github.repository }}" pr_view_labels=$(gh pr view ${PR_NUMBER} --repo ${GITHUB_REPO} --json "labels") pr_labels=$(echo "${pr_view_labels}" | jq -r '.labels[].name') + echo "PR LABELS:"$pr_labels if [[ "${pr_labels}" == *"approved"* || "${pr_labels}" == *"pre-approve"* ]]; then TRIGGER_RUN="true" fi