Skip to content

Commit 19028e8

Browse files
Copilotmarilene38
andcommitted
feat: update auto-close-pr workflow to close fork PRs only with least-privilege permissions
Co-authored-by: marilene38 <135267736+marilene38@users.noreply.github.com>
1 parent 47963ae commit 19028e8

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
name: Auto-close PR
2+
23
on:
34
pull_request_target:
4-
types: [opened, reopened]
5+
types: [opened, reopened, synchronize]
6+
7+
permissions:
8+
pull-requests: write
9+
10+
concurrency:
11+
group: auto-close-pr-${{ github.event.pull_request.number }}
12+
cancel-in-progress: true
513

614
jobs:
715
close:
8-
name: Run
16+
name: Close fork PRs with guidance
917
runs-on: ubuntu-latest
10-
permissions:
11-
pull-requests: write
1218
steps:
13-
- run: |
14-
gh pr close ${{ github.event.pull_request.number }} --comment \
15-
"At the moment we are not accepting contributions to the repository.
16-
17-
Feedback for GitHub Copilot for Xcode can be given in the [Copilot community discussions](https://github.com/orgs/community/discussions/categories/copilot)."
19+
- name: Close PR from fork with message
20+
if: >-
21+
github.event.pull_request.head.repo.full_name != github.repository &&
22+
github.event.pull_request.state == 'open'
1823
env:
1924
GH_REPO: ${{ github.repository }}
2025
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
PR_NUMBER: ${{ github.event.pull_request.number }}
27+
run: |
28+
set -euo pipefail
29+
gh pr close "$PR_NUMBER" \
30+
--reason not_planned \
31+
--comment "$(cat <<'EOF'
32+
Thanks for the pull request! At the moment we are not accepting contributions to this repository.
33+
34+
Feedback for GitHub Copilot for Xcode can be shared in the Copilot community discussions:
35+
https://github.com/orgs/community/discussions/categories/copilot
36+
EOF
37+
)"

0 commit comments

Comments
 (0)