diff --git a/.github/workflows/build-frontends.yml b/.github/workflows/build-frontends.yml index 591c5c899..160b521d8 100644 --- a/.github/workflows/build-frontends.yml +++ b/.github/workflows/build-frontends.yml @@ -10,27 +10,11 @@ permissions: contents: read jobs: - # Skip push builds for branches whose open PR (base master/release/*) already builds - # them via the pull_request trigger. Pushes to master/release/* always build. + # Skip push builds for branches whose open PR already builds them; see pr-build-gate.yml. gate: - runs-on: ubuntu-latest permissions: pull-requests: read - outputs: - run: ${{ steps.check.outputs.run }} - steps: - - id: check - env: - GH_TOKEN: ${{ github.token }} - run: | - prs=0 - case "$GITHUB_EVENT_NAME/$GITHUB_REF_NAME" in - push/master|push/release/*) ;; - push/*) prs=$(gh api -X GET "repos/$GITHUB_REPOSITORY/pulls" -f state=open \ - -f head="$GITHUB_REPOSITORY_OWNER:$GITHUB_REF_NAME" \ - --jq 'map(select(.base.ref == "master" or (.base.ref | startswith("release/")))) | length') ;; - esac - echo "run=$([ "$prs" = 0 ] && echo true || echo false)" >> "$GITHUB_OUTPUT" + uses: ./.github/workflows/pr-build-gate.yml build: needs: gate diff --git a/.github/workflows/build-ilspy.yml b/.github/workflows/build-ilspy.yml index e1de308ea..97d10d563 100644 --- a/.github/workflows/build-ilspy.yml +++ b/.github/workflows/build-ilspy.yml @@ -15,27 +15,11 @@ env: StagingDirectory: buildartifacts jobs: - # Skip push builds for branches whose open PR (base master/release/*) already builds - # them via the pull_request trigger. Pushes to master/release/* always build (they publish). + # Skip push builds for branches whose open PR already builds them; see pr-build-gate.yml. Gate: - runs-on: ubuntu-latest permissions: pull-requests: read - outputs: - run: ${{ steps.check.outputs.run }} - steps: - - id: check - env: - GH_TOKEN: ${{ github.token }} - run: | - prs=0 - case "$GITHUB_EVENT_NAME/$GITHUB_REF_NAME" in - push/master|push/release/*) ;; - push/*) prs=$(gh api -X GET "repos/$GITHUB_REPOSITORY/pulls" -f state=open \ - -f head="$GITHUB_REPOSITORY_OWNER:$GITHUB_REF_NAME" \ - --jq 'map(select(.base.ref == "master" or (.base.ref | startswith("release/")))) | length') ;; - esac - echo "run=$([ "$prs" = 0 ] && echo true || echo false)" >> "$GITHUB_OUTPUT" + uses: ./.github/workflows/pr-build-gate.yml Build: name: Desktop (Windows) diff --git a/.github/workflows/pr-build-gate.yml b/.github/workflows/pr-build-gate.yml new file mode 100644 index 000000000..a0b436bd4 --- /dev/null +++ b/.github/workflows/pr-build-gate.yml @@ -0,0 +1,32 @@ +name: PR build gate + +on: + workflow_call: + outputs: + run: + description: Whether the push-triggered build should run + value: ${{ jobs.gate.outputs.run }} + +jobs: + # Skip push builds for branches whose open PR (base master/release/*) already builds + # them via the pull_request trigger. Pushes to master/release/* always build (they + # may publish packages, and no PR of theirs may suppress that). + gate: + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + run: ${{ steps.check.outputs.run }} + steps: + - id: check + env: + GH_TOKEN: ${{ github.token }} + run: | + prs=0 + case "$GITHUB_EVENT_NAME/$GITHUB_REF_NAME" in + push/master|push/release/*) ;; + push/*) prs=$(gh api -X GET "repos/$GITHUB_REPOSITORY/pulls" -f state=open \ + -f head="$GITHUB_REPOSITORY_OWNER:$GITHUB_REF_NAME" \ + --jq 'map(select(.base.ref == "master" or (.base.ref | startswith("release/")))) | length') ;; + esac + echo "run=$([ "$prs" = 0 ] && echo true || echo false)" >> "$GITHUB_OUTPUT"