Skip to content

Commit 773cd7f

Browse files
authored
chore: check pr run (#9559)
1 parent 6759437 commit 773cd7f

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

.github/workflows/cicd-pull-request.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ on:
99

1010
env:
1111
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
12+
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
1213
BASE_BRANCH: origin/main
1314
GO_VERSION: "1.23"
1415

1516
jobs:
1617
trigger-mode:
1718
name: trigger mode
18-
if: github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'pre-approve')
19+
if: github.event.action == 'labeled'
1920
runs-on: ubuntu-latest
2021
outputs:
2122
trigger-mode: ${{ steps.get_trigger_mode.outputs.trigger_mode }}
23+
trigger-run: ${{ steps.get_trigger_run.outputs.trigger_run }}
2224
git-commit: ${{ steps.get_git_info.outputs.git_commit }}
2325
git-version: ${{ steps.get_git_info.outputs.git_version }}
2426
steps:
@@ -33,7 +35,22 @@ jobs:
3335
fetch-depth: 0
3436
repository: ${{ github.event.pull_request.head.repo.full_name }}
3537

38+
- name: check run
39+
id: get_trigger_run
40+
run: |
41+
TRIGGER_RUN="false"
42+
PR_NUMBER="${{ github.event.pull_request.number }}"
43+
GITHUB_REPO="${{ github.repository }}"
44+
pr_view_labels=$(gh pr view ${PR_NUMBER} --repo ${GITHUB_REPO} --json "labels")
45+
pr_labels=$(echo "${pr_view_labels}" | jq -r '.labels[].name')
46+
echo "PR LABELS:"$pr_labels
47+
if [[ "${pr_labels}" == *"approved"* || "${pr_labels}" == *"pre-approve"* ]]; then
48+
TRIGGER_RUN="true"
49+
fi
50+
echo "trigger_run="$TRIGGER_RUN >> $GITHUB_OUTPUT
51+
3652
- name: Get trigger mode
53+
if: ${{ steps.get_trigger_run.outputs.trigger_run == 'true' }}
3754
id: get_trigger_mode
3855
env:
3956
HEAD_REF: ${{ github.event.pull_request.head.ref }}
@@ -167,7 +184,7 @@ jobs:
167184
pr-check:
168185
name: make test
169186
needs: [ trigger-mode, pr-pre-check, check-image, check-tools-image, check-dataprotection-image, check-helm ]
170-
if: ${{ github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'pre-approve') && always() }}
187+
if: ${{ github.event.action == 'labeled' && needs.trigger-mode.outputs.trigger-run == 'true' && always() }}
171188
runs-on: ubuntu-latest
172189
steps:
173190
- name: pr pre check

0 commit comments

Comments
 (0)