mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
The gate job was copy-pasted into build-ilspy.yml and build-frontends.yml and the two copies had already started drifting (job casing, comment wording). A workflow_call workflow keeps a single definition; the callers shrink to a uses: job and route its "run" output to their build jobs unchanged. Each caller must still grant pull-requests: read explicitly, because the called workflow's token is the intersection of what the caller grants and what the callee requests, and both callers default to contents: read only. Assisted-by: Claude:claude-fable-5:Claude Codepull/3942/head
3 changed files with 36 additions and 36 deletions
@ -0,0 +1,32 @@
@@ -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" |
||||
Loading…
Reference in new issue