-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (61 loc) · 2.21 KB
/
spec-check.yml
File metadata and controls
70 lines (61 loc) · 2.21 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: Spec Check
on:
repository_dispatch:
types: [spec_updated]
permissions:
contents: write
issues: write
pull-requests: write
jobs:
check-compatibility:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Download latest OpenAPI spec from monorepo
run: |
gh api repos/devhelmhq/mono/contents/docs/openapi/monitoring-api.json \
-H "Accept: application/vnd.github.raw+json" \
> docs/openapi/monitoring-api.json
env:
GH_TOKEN: ${{ secrets.MONOREPO_DISPATCH_TOKEN }}
- run: npm ci
- run: npm run build
- run: npm test
- name: Regenerate types from spec
run: npm run typegen
- name: Check for type changes
id: diff
run: |
if git diff --quiet src/lib/api.generated.ts docs/openapi/; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Open PR with updated types
if: steps.diff.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
branch="chore/update-api-types-$(date +%Y%m%d%H%M%S)"
git checkout -b "$branch"
git add src/lib/api.generated.ts docs/openapi/monitoring-api.json
git commit -m "chore: update generated API types from latest spec"
git push -u origin "$branch"
gh pr create \
--title "chore: update generated API types" \
--body "Auto-generated from latest OpenAPI spec in the monorepo." \
--base main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Report failure
if: failure()
run: |
gh issue create \
--title "⚠️ API spec change broke CLI build" \
--body "The monorepo pushed a spec update that caused CI failures.\n\nWorkflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}