From c5fbd29c0e018f874c27530c887152ab43ef9a7d Mon Sep 17 00:00:00 2001 From: Luna Yao <40349250+ZnqbuZ@users.noreply.github.com> Date: Thu, 9 Apr 2026 03:45:04 +0200 Subject: [PATCH] ci: fix skip condition for draft pull requests in CI workflows (#2088) * ci: run xxx-result only when pre_job is run successfully * fix get-result steps --- .github/workflows/core.yml | 19 +++++++------------ .github/workflows/gui.yml | 11 +++++------ .github/workflows/mobile.yml | 11 +++++------ .github/workflows/ohos.yml | 3 ++- .github/workflows/test.yml | 6 +++--- 5 files changed, 22 insertions(+), 28 deletions(-) diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml index 8402d490..f2df8fb5 100644 --- a/.github/workflows/core.yml +++ b/.github/workflows/core.yml @@ -23,10 +23,11 @@ jobs: pre_job: # continue-on-error: true # Uncomment once integration is finished runs-on: ubuntu-latest + if: github.event_name != 'pull_request' || !github.event.pull_request.draft # Map a step output to a job output outputs: # do not skip push on branch starts with releases/ - should_skip: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft) || (steps.skip_check.outputs.should_skip == 'true' && !startsWith(github.ref_name, 'releases/')) }} + should_skip: ${{ steps.skip_check.outputs.should_skip == 'true' && !startsWith(github.ref_name, 'releases/') }} steps: - id: skip_check uses: fkirc/skip-duplicate-actions@v5 @@ -279,24 +280,18 @@ jobs: ./artifacts/* core-result: - if: needs.pre_job.outputs.should_skip != 'true' && always() runs-on: ubuntu-latest - needs: - - pre_job - - build_web - - build + needs: [ pre_job, build_web, build ] + if: needs.pre_job.result == 'success' && needs.pre_job.outputs.should_skip != 'true' && !cancelled() steps: - name: Mark result as failed - if: needs.build.result != 'success' + if: contains(needs.*.result, 'failure') run: exit 1 magisk_build: - needs: - - pre_job - - build_web - - build - if: needs.pre_job.outputs.should_skip != 'true' && always() runs-on: ubuntu-latest + needs: [ pre_job, build_web, build ] + if: needs.pre_job.result == 'success' && needs.pre_job.outputs.should_skip != 'true' && !cancelled() steps: - name: Checkout Code uses: actions/checkout@v5 # 必须先检出代码才能获取模块配置 diff --git a/.github/workflows/gui.yml b/.github/workflows/gui.yml index 994c8981..77c75496 100644 --- a/.github/workflows/gui.yml +++ b/.github/workflows/gui.yml @@ -23,9 +23,10 @@ jobs: pre_job: # continue-on-error: true # Uncomment once integration is finished runs-on: ubuntu-latest + if: github.event_name != 'pull_request' || !github.event.pull_request.draft # Map a step output to a job output outputs: - should_skip: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft) || (steps.skip_check.outputs.should_skip == 'true' && !startsWith(github.ref_name, 'releases/')) }} + should_skip: ${{ steps.skip_check.outputs.should_skip == 'true' && !startsWith(github.ref_name, 'releases/') }} steps: - id: skip_check uses: fkirc/skip-duplicate-actions@v5 @@ -206,12 +207,10 @@ jobs: ./artifacts/* gui-result: - if: needs.pre_job.outputs.should_skip != 'true' && always() runs-on: ubuntu-latest - needs: - - pre_job - - build-gui + needs: [ pre_job, build-gui ] + if: needs.pre_job.result == 'success' && needs.pre_job.outputs.should_skip != 'true' && !cancelled() steps: - name: Mark result as failed - if: needs.build-gui.result != 'success' + if: contains(needs.*.result, 'failure') run: exit 1 diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 74df2452..4276f404 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -23,9 +23,10 @@ jobs: pre_job: # continue-on-error: true # Uncomment once integration is finished runs-on: ubuntu-latest + if: github.event_name != 'pull_request' || !github.event.pull_request.draft # Map a step output to a job output outputs: - should_skip: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft) || (steps.skip_check.outputs.should_skip == 'true' && !startsWith(github.ref_name, 'releases/')) }} + should_skip: ${{ steps.skip_check.outputs.should_skip == 'true' && !startsWith(github.ref_name, 'releases/') }} steps: - id: skip_check uses: fkirc/skip-duplicate-actions@v5 @@ -125,12 +126,10 @@ jobs: ./artifacts/* mobile-result: - if: needs.pre_job.outputs.should_skip != 'true' && always() runs-on: ubuntu-latest - needs: - - pre_job - - build-mobile + needs: [ pre_job, build-mobile ] + if: needs.pre_job.result == 'success' && needs.pre_job.outputs.should_skip != 'true' && !cancelled() steps: - name: Mark result as failed - if: needs.build-mobile.result != 'success' + if: contains(needs.*.result, 'failure') run: exit 1 diff --git a/.github/workflows/ohos.yml b/.github/workflows/ohos.yml index 292a9f79..39371112 100644 --- a/.github/workflows/ohos.yml +++ b/.github/workflows/ohos.yml @@ -38,10 +38,11 @@ jobs: pre_job: # continue-on-error: true # Uncomment once integration is finished runs-on: ubuntu-latest + if: github.event_name != 'pull_request' || !github.event.pull_request.draft # Map a step output to a job output outputs: # do not skip push on branch starts with releases/ - should_skip: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft) || (steps.skip_check.outputs.should_skip == 'true' && !startsWith(github.ref_name, 'releases/')) }} + should_skip: ${{ steps.skip_check.outputs.should_skip == 'true' && !startsWith(github.ref_name, 'releases/') }} steps: - id: skip_check uses: fkirc/skip-duplicate-actions@v5 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 01d9d37d..5f624d4f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -150,9 +150,9 @@ jobs: test: runs-on: ubuntu-latest - needs: [ pre_job, test_matrix ] - if: needs.pre_job.outputs.should_skip != 'true' && always() + needs: [ pre_job, check, test_matrix ] + if: needs.pre_job.result == 'success' && needs.pre_job.outputs.should_skip != 'true' && !cancelled() steps: - name: Mark result as failed - if: needs.test_matrix.result != 'success' + if: contains(needs.*.result, 'failure') run: exit 1