From 89b5776a45e5dbc36006b1ce65813a8e42cd1327 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Jul 2026 15:07:09 +0200 Subject: [PATCH] ci: skip redundant build re-runs on same-repo PRs Bare push + pull_request triggers meant every commit was re-validated as it walked develop -> PR -> main. Guard the build job so same-repo PRs (develop->main releases, Dependabot PRs) rely on their branch's push run, which branch protection already reads per head SHA. Fork PRs still build, since fork branches don't fire push here. ci-success now treats a skipped build as a pass so main's required gate stays green without rebuilding. --- .github/workflows/ci.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7dd529..aef58d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,13 @@ permissions: jobs: build: + # Skip the redundant re-run for same-repo PRs. A branch push already ran this + # exact commit through CI, and branch-protection reads status per head SHA + # regardless of the triggering event - so a develop->main release PR (or a + # Dependabot PR into develop) is already validated by its branch's push run. + # Fork PRs are the exception: a fork branch never fires `push` here, so they + # still need the pull_request run. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository # Type-check, test, and build are OS-independent, so a single Linux runner is # enough. Pinned to Node 24 (current Active LTS), matching engines and the # CONTRIBUTING support claim. @@ -44,7 +51,11 @@ jobs: steps: - name: Verify the build job succeeded run: | - if [ "${{ needs.build.result }}" != "success" ]; then - echo "::error::build job did not succeed (result: ${{ needs.build.result }})" + # 'skipped' means a same-repo PR whose head commit the branch push + # already validated (see the build job's if:) - treat it as a pass so + # the required ci-success gate still reports green without re-building. + result="${{ needs.build.result }}" + if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then + echo "::error::build job did not succeed (result: $result)" exit 1 fi