Skip to content

Commit 2e6bf67

Browse files
kim-emclaude
andcommitted
chore: check for empty PRs in CI
This PR adds a CI check that fails when a PR introduces no changes compared to its base branch. This catches cases where a duplicate PR is queued for merge after an identical PR has already landed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bf4f51e commit 2e6bf67

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Check for empty PR
2+
3+
on:
4+
merge_group:
5+
pull_request:
6+
7+
jobs:
8+
check-empty-pr:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v6
12+
with:
13+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
14+
fetch-depth: 0
15+
filter: tree:0
16+
17+
- name: Check for empty diff
18+
run: |
19+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
20+
base=$(git merge-base "origin/${{ github.base_ref }}" HEAD)
21+
else
22+
base=$(git rev-parse HEAD^1)
23+
fi
24+
if git diff --quiet "$base" HEAD --; then
25+
echo "This PR introduces no changes compared to its base branch." | tee "$GITHUB_STEP_SUMMARY"
26+
echo "It may be a duplicate of an already-merged PR." | tee -a "$GITHUB_STEP_SUMMARY"
27+
exit 1
28+
fi
29+
shell: bash

0 commit comments

Comments
 (0)