Skip to content

Commit 1b3ffb0

Browse files
committed
refactor(ci): split workflows into PR checks, shared checks, and deploy
- _checks.yml: reusable workflow with validation, freshness, and version bump checks - ci.yml: PR-only trigger, calls _checks.yml (shows as "PR / checks / validate") - deploy.yml: push-to-main only, calls _checks.yml then builds and deploys
1 parent 13e6bea commit 1b3ffb0

3 files changed

Lines changed: 72 additions & 40 deletions

File tree

.github/workflows/_checks.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Checks
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
validate:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
cache: npm
19+
- run: npm ci
20+
- run: node scripts/validate-skills.js
21+
- name: Verify generated files are up to date
22+
run: |
23+
npm run generate
24+
git diff --exit-code public/ || {
25+
echo "::error::Generated files are out of date. Run 'npm run generate' and commit the results."
26+
exit 1
27+
}
28+
- name: Check version bumps for changed skills
29+
run: |
30+
if [ -n "${{ github.base_ref }}" ]; then
31+
base="origin/${{ github.base_ref }}"
32+
else
33+
base="HEAD~1"
34+
fi
35+
changed=$(git diff --name-only "$base" -- 'skills/*/SKILL.md')
36+
if [ -z "$changed" ]; then
37+
echo "No SKILL.md files changed"
38+
exit 0
39+
fi
40+
fail=0
41+
for file in $changed; do
42+
if ! git show "$base":"$file" > /dev/null 2>&1; then
43+
echo "NEW: $file (no version check needed)"
44+
continue
45+
fi
46+
old_version=$(git show "$base":"$file" | grep '^version:' | head -1 | awk '{print $2}')
47+
new_version=$(grep '^version:' "$file" | head -1 | awk '{print $2}')
48+
if [ "$old_version" = "$new_version" ]; then
49+
echo "::error::$file was changed but version was not bumped (still $old_version). See CONTRIBUTING.md for versioning rules."
50+
fail=1
51+
else
52+
echo "OK: $file ($old_version -> $new_version)"
53+
fi
54+
done
55+
exit $fail

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
group: ci-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
checks:
12+
uses: ./.github/workflows/_checks.yml

.github/workflows/deploy.yml

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,37 @@ name: Deploy to GitHub Pages
33
on:
44
push:
55
branches: [main]
6-
pull_request:
76
workflow_dispatch:
87

98
concurrency:
10-
group: pages-${{ github.ref }}
9+
group: pages
1110
cancel-in-progress: true
1211

1312
jobs:
13+
checks:
14+
uses: ./.github/workflows/_checks.yml
15+
1416
build:
17+
needs: checks
1518
runs-on: ubuntu-latest
1619
permissions:
1720
contents: read
1821
steps:
1922
- uses: actions/checkout@v4
20-
with:
21-
fetch-depth: 0
2223
- uses: actions/setup-node@v4
2324
with:
2425
node-version: 20
2526
cache: npm
2627
- run: npm ci
27-
- run: node scripts/validate-skills.js
28-
- name: Verify generated files are up to date
29-
run: |
30-
npm run generate
31-
git diff --exit-code public/ || {
32-
echo "::error::Generated files are out of date. Run 'npm run generate' and commit the results."
33-
exit 1
34-
}
35-
- name: Check version bumps for changed skills
36-
if: github.event_name == 'pull_request'
37-
run: |
38-
changed=$(git diff --name-only origin/${{ github.base_ref }} -- 'skills/*/SKILL.md')
39-
if [ -z "$changed" ]; then
40-
echo "No SKILL.md files changed"
41-
exit 0
42-
fi
43-
fail=0
44-
for file in $changed; do
45-
# Skip new files (no base branch version to compare)
46-
if ! git show origin/${{ github.base_ref }}:"$file" > /dev/null 2>&1; then
47-
echo "NEW: $file (no version check needed)"
48-
continue
49-
fi
50-
old_version=$(git show origin/${{ github.base_ref }}:"$file" | grep '^version:' | head -1 | awk '{print $2}')
51-
new_version=$(grep '^version:' "$file" | head -1 | awk '{print $2}')
52-
if [ "$old_version" = "$new_version" ]; then
53-
echo "::error::$file was changed but version was not bumped (still $old_version). See CONTRIBUTING.md for versioning rules."
54-
fail=1
55-
else
56-
echo "OK: $file ($old_version -> $new_version)"
57-
fi
58-
done
59-
exit $fail
6028
- run: npm run build
6129
- uses: actions/upload-pages-artifact@v3
62-
if: github.event_name != 'pull_request'
6330
with:
6431
path: dist
6532

6633
deploy:
6734
needs: build
68-
if: github.event_name != 'pull_request'
6935
runs-on: ubuntu-latest
7036
permissions:
71-
contents: read
7237
pages: write
7338
id-token: write
7439
environment:

0 commit comments

Comments
 (0)