Skip to content

Commit cb3e406

Browse files
authored
Assert proposal number matches PR number (#20)
Signed-off-by: Nicholas Gates <nick@nickgates.com>
1 parent c3801e5 commit cb3e406

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,35 @@ jobs:
3636
- name: Install dependencies
3737
run: bun install
3838

39+
- name: Check proposal matches PR number
40+
run: |
41+
BASE_SHA="${{ github.event.pull_request.base.sha }}"
42+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
43+
PR_NUMBER="${{ github.event.pull_request.number }}"
44+
45+
CHANGED_PROPOSALS=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- 'proposals/' \
46+
| grep -v '^proposals/0000-template\.md$' || true)
47+
48+
COUNT=$(echo "$CHANGED_PROPOSALS" | grep -c . || true)
49+
50+
if [ "$COUNT" -gt 1 ]; then
51+
echo "::error::PR touches $COUNT proposals. Only one proposal per PR is allowed."
52+
echo "$CHANGED_PROPOSALS"
53+
exit 1
54+
fi
55+
56+
if [ "$COUNT" -eq 1 ]; then
57+
FILE=$(echo "$CHANGED_PROPOSALS" | head -1)
58+
FILENAME=$(basename "$FILE")
59+
FILE_NUMBER=$(echo "$FILENAME" | grep -oE '^[0-9]+' || true)
60+
# Strip leading zeros for comparison
61+
FILE_NUM=$((10#$FILE_NUMBER))
62+
63+
if [ "$FILE_NUM" -ne "$PR_NUMBER" ]; then
64+
echo "::error::Proposal number ($FILE_NUM from $FILENAME) does not match PR number ($PR_NUMBER)."
65+
exit 1
66+
fi
67+
fi
68+
3969
- name: Build
4070
run: bun run build

0 commit comments

Comments
 (0)