-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (56 loc) · 1.84 KB
/
ci.yml
File metadata and controls
70 lines (56 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: CI
on:
pull_request:
branches:
- develop
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Lint all code
run: bunx prettier --check .
build:
env:
GH_TOKEN: ${{ github.token }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Check proposal matches PR number
run: |
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
CHANGED_PROPOSALS=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- 'proposals/' \
| grep -v '^proposals/0000-template\.md$' || true)
COUNT=$(echo "$CHANGED_PROPOSALS" | grep -c . || true)
if [ "$COUNT" -gt 1 ]; then
echo "::error::PR touches $COUNT proposals. Only one proposal per PR is allowed."
echo "$CHANGED_PROPOSALS"
exit 1
fi
if [ "$COUNT" -eq 1 ]; then
FILE=$(echo "$CHANGED_PROPOSALS" | head -1)
FILENAME=$(basename "$FILE")
FILE_NUMBER=$(echo "$FILENAME" | grep -oE '^[0-9]+' || true)
# Strip leading zeros for comparison
FILE_NUM=$((10#$FILE_NUMBER))
if [ "$FILE_NUM" -ne "$PR_NUMBER" ]; then
echo "::error::Proposal number ($FILE_NUM from $FILENAME) does not match PR number ($PR_NUMBER)."
exit 1
fi
fi
- name: Build
run: bun run build