Update API Specification #28
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: Create Pull Request | |
| if: env.spec_changed == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Create branch name with timestamp | |
| BRANCH_NAME="update-api-spec/$(date +%Y%m%d-%H%M%S)" | |
| # Create and checkout new branch | |
| git checkout -b "$BRANCH_NAME" | |
| # 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/swagger.json" \ | |
| -m "Updated on $(date -u '+%Y-%m-%d %H:%M:%S UTC')" | |
| # Push branch | |
| git push origin "$BRANCH_NAME" | |
| # Create pull request | |
| gh pr create \ | |
| --title "🔄 Update API Specification - $(date +%Y-%m-%d)" \ | |
| --body "## 📋 Summary | |
| This PR updates the API specification with the latest changes from the live Checkly API endpoint. | |
| ## 🔄 Changes | |
| - Updated \`api-reference/openapi.json\` from https://api.checklyhq.com/swagger.json | |
| - Converted from Swagger 2.0 to OpenAPI 3.0 format | |
| - Validated specification with Mintlify | |
| ## 🤖 Automation | |
| This PR was automatically created by the \`update-api-spec.yml\` GitHub Action that runs every 48 hours. | |
| ## ✅ Validation | |
| The updated specification has been validated and is compatible with Mintlify documentation." \ | |
| --head "$BRANCH_NAME" \ | |
| --base main \ | |
| --label "documentation" | |
| - name: Report no changes | |
| if: env.spec_changed == 'false' | |
| run: | | |
| echo "✅ API specification is up to date - no changes needed" |