[CI] fix CI skipped on main (#13527)

This commit is contained in:
Liangsheng Yin
2025-11-19 01:19:08 +08:00
committed by GitHub
parent d79e12941c
commit f5566acc2a
+5 -3
View File
@@ -14,10 +14,10 @@ jobs:
pr-gate: pr-gate:
# 1. for commits on main: no gating needed # 1. for commits on main: no gating needed
# 2. for workflow_dispatch: this can only be triggered by users with write access # 2. for workflow_dispatch: this can only be triggered by users with write access
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Fetch latest PR info - name: Fetch latest PR info
if: github.event_name == 'pull_request'
id: pr id: pr
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
@@ -33,6 +33,7 @@ jobs:
core.setOutput("user", pr.data.user.login); core.setOutput("user", pr.data.user.login);
- name: Log PR info - name: Log PR info
if: github.event_name == 'pull_request'
run: | run: |
echo "===== PR Info =====" echo "===== PR Info ====="
echo "PR Event: ${{ github.event_name }}" echo "PR Event: ${{ github.event_name }}"
@@ -44,13 +45,13 @@ jobs:
echo "===================" echo "==================="
- name: Block draft PR - name: Block draft PR
if: fromJson(steps.pr.outputs.draft) if: github.event_name == 'pull_request' && fromJson(steps.pr.outputs.draft)
run: | run: |
echo "PR is draft. Blocking CI." echo "PR is draft. Blocking CI."
exit 1 exit 1
- name: Require run-ci label (optional) - name: Require run-ci label (optional)
if: inputs.require-run-ci == true if: github.event_name == 'pull_request' && inputs.require-run-ci == true
run: | run: |
labels='${{ steps.pr.outputs.labels }}' labels='${{ steps.pr.outputs.labels }}'
if [[ "${{ contains(fromJson(steps.pr.outputs.labels), 'run-ci') }}" == "false" ]]; then if [[ "${{ contains(fromJson(steps.pr.outputs.labels), 'run-ci') }}" == "false" ]]; then
@@ -59,6 +60,7 @@ jobs:
fi fi
- name: Enforce rate limit for low-permission actors (optional) - name: Enforce rate limit for low-permission actors (optional)
if: github.event_name == 'pull_request' && inputs.rate-limit-hours > 0
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}