Update API Specification #65
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 "[email protected]" | |
| - 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" |