feat(ci): auto-close pull requests with no net changes#312
Merged
Conversation
Bot authors sometimes open PRs that have commits but a 0-file diff vs. base (GitHub shows "No files changed / +0 -0"). Add a central pull_request_target workflow that closes such empty PRs (leaving drafts alone) so humans do not have to. Uses a write token without checking out PR code, so no code-execution risk. Add close-empty-pr.yml to the org required-workflows list to run per repo. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RTAMs4bpSZS77Xe3RQjv9P
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
목적
봇이 커밋은 있으나 base 대비 실제 변경(diff)이 0건인 PR(GitHub "No files changed / +0 -0")을 자동으로 닫습니다. (사용자 요청: "커밋을 했는데 변경 사항이 0이라면 자동으로 Close")
동작
close-empty-pr.yml—pull_request_target(opened/synchronize/reopened/ready_for_review)changed_files == 0이면 코멘트 남기고 close. draft는 건드리지 않음.pull_request_target이지만 PR 코드를 checkout하지 않고 PR 메타데이터만 읽어 close하므로 인젝션 위험 없음. 리포별 write 토큰 사용.후속 (머지 후)
조직 룰셋
workflows필수 목록에close-empty-pr.yml추가(전 리포에서 실행). #310 security-scan 스왑과 함께 일괄 반영.참고
지금 열려 있던 빈 PR 2건(
.github#308,newsdom-api#264)은 이미 수동 스윕으로 닫았습니다.🤖 Generated with Claude Code