-
Notifications
You must be signed in to change notification settings - Fork 8
77 lines (61 loc) · 2.12 KB
/
update-api-spec.yml
File metadata and controls
77 lines (61 loc) · 2.12 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
71
72
73
74
75
76
name: Update API Specification
on:
schedule:
# Run every 48 hours (at 2 AM UTC every 2 days)
- cron: '0 2 */2 * *'
workflow_dispatch: # Allow manual triggering
jobs:
update-api-spec:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
npm install -g swagger2openapi
npm install -g mintlify
- name: Configure git
run: |
git config user.name "API Spec Updater"
git config user.email "noreply@checkly.com"
- name: Fetch and update API specification
run: |
# Store current spec hash for comparison
CURRENT_HASH=$(sha256sum api-reference/openapi.json | cut -d' ' -f1)
# Run the update script
./update-api-spec.sh
# Check if spec actually changed
NEW_HASH=$(sha256sum api-reference/openapi.json | cut -d' ' -f1)
if [ "$CURRENT_HASH" != "$NEW_HASH" ]; then
echo "API specification has changed"
echo "spec_changed=true" >> $GITHUB_ENV
else
echo "API specification is unchanged"
echo "spec_changed=false" >> $GITHUB_ENV
fi
- name: Commit and Push Changes
if: env.spec_changed == 'true'
run: |
# Commit changes
git add api-reference/openapi.json
git commit -m "Update API specification from live endpoint" \
-m "Automatically fetched from https://api.checklyhq.com/openapi.json" \
-m "Updated on $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
# Push directly to main
git push origin main
- name: Report no changes
if: env.spec_changed == 'false'
run: |
echo "✅ API specification is up to date - no changes needed"
- name: Ping Checkly
run: curl -fsS --retry 3 https://ping.checklyhq.com/ad576f21-3f3e-4a6a-b8e4-67fd0f6ed92d