1+ name : Update OpenAPI Specification
2+
3+ on :
4+ workflow_dispatch :
5+ jobs :
6+ update-openapi :
7+ runs-on : ubuntu-latest
8+ permissions :
9+ contents : write
10+ pull-requests : write
11+ steps :
12+ - name : Checkout repository
13+ uses : actions/checkout@v4
14+
15+ - name : Fetch OpenAPI specification
16+ run : |
17+ curl -s https://api.vapi.ai/api-json > temp-openapi.json
18+
19+ - name : Verify JSON validity
20+ run : |
21+ cat temp-openapi.json | jq . > /dev/null
22+ if [ $? -ne 0 ]; then
23+ echo "Error: Invalid JSON received from API endpoint"
24+ exit 1
25+ fi
26+ mv temp-openapi.json ./fern/apis/api/openapi.json
27+
28+ - name : Check for changes
29+ id : check_changes
30+ run : |
31+ if git diff --quiet ./fern/apis/api/openapi.json; then
32+ echo "No changes detected in OpenAPI specification"
33+ echo "changes_detected=false" >> $GITHUB_OUTPUT
34+ else
35+ echo "Changes detected in OpenAPI specification"
36+ echo "changes_detected=true" >> $GITHUB_OUTPUT
37+ fi
38+
39+ - name : Setup GitHub CLI
40+ id : setup_cli
41+ if : steps.check_changes.outputs.changes_detected == 'true'
42+ run : |
43+ # Create timestamp for unique branch name
44+ TIMESTAMP=$(date +%Y%m%d%H%M%S)
45+ BRANCH_NAME="update-openapi-spec-${TIMESTAMP}"
46+
47+ # Setup branch for changes
48+ git config --global user.name "GitHub Actions"
49+ git config --global user.email "[email protected] " 50+
51+ # Create new branch with timestamp
52+ git checkout -b $BRANCH_NAME
53+ git add ./fern/apis/api/openapi.json
54+ git commit -m "chore: update OpenAPI specification"
55+ git push -u origin $BRANCH_NAME
56+
57+ # Store branch name for PR creation
58+ echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
59+
60+ - name : Create Pull Request with GitHub CLI
61+ if : steps.check_changes.outputs.changes_detected == 'true'
62+ run : |
63+ gh pr create \
64+ --base main \
65+ --head ${{ steps.setup_cli.outputs.branch_name }} \
66+ --title "Update OpenAPI Specification" \
67+ --body "This PR updates the OpenAPI specification from the official Vapi API endpoint.
68+
69+ - Auto-generated by the Update OpenAPI Specification workflow
70+ - Source: https://api.vapi.ai/api-json
71+ - Generated at: $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
72+ env :
73+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
74+
75+ - name : PR Result
76+ if : steps.check_changes.outputs.changes_detected == 'true'
77+ run : |
78+ echo "Pull request created successfully!"
79+
80+ - name : No Changes Result
81+ if : steps.check_changes.outputs.changes_detected == 'false'
82+ run : |
83+ echo "No changes detected in OpenAPI specification. No PR created."
0 commit comments