Skip to content

Commit 310f8f2

Browse files
Simplify/update GitHub workflow for nightly openapi spec updates (#382)
* push new workflow * rename --------- Co-authored-by: Sahil Chatiwala <sahilchatiwala@gmail.com>
1 parent 75b4c74 commit 310f8f2

File tree

1 file changed

+10
-64
lines changed

1 file changed

+10
-64
lines changed

.github/workflows/update-openapi.yml

+10-64
Original file line numberDiff line numberDiff line change
@@ -12,67 +12,13 @@ jobs:
1212
contents: write
1313
pull-requests: write
1414
steps:
15-
- name: Checkout repository
16-
uses: actions/checkout@v4
17-
18-
- name: Fetch OpenAPI specification
19-
run: |
20-
npm install -g fern-api
21-
fern api update
22-
23-
- name: Check for changes
24-
id: check_changes
25-
run: |
26-
if git diff --quiet ./fern/apis/api/openapi.json; then
27-
echo "No changes detected in OpenAPI specification"
28-
echo "changes_detected=false" >> $GITHUB_OUTPUT
29-
else
30-
echo "Changes detected in OpenAPI specification"
31-
echo "changes_detected=true" >> $GITHUB_OUTPUT
32-
fi
33-
34-
- name: Setup GitHub CLI
35-
id: setup_cli
36-
if: steps.check_changes.outputs.changes_detected == 'true'
37-
run: |
38-
# Create timestamp for unique branch name
39-
TIMESTAMP=$(date +%Y%m%d%H%M%S)
40-
BRANCH_NAME="update-openapi-spec-${TIMESTAMP}"
41-
42-
# Setup branch for changes
43-
git config --global user.name "GitHub Actions"
44-
git config --global user.email "actions@github.com"
45-
46-
# Create new branch with timestamp
47-
git checkout -b $BRANCH_NAME
48-
git add ./fern/apis/api/openapi.json
49-
git commit -m "chore: update OpenAPI specification"
50-
git push -u origin $BRANCH_NAME
51-
52-
# Store branch name for PR creation
53-
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
54-
55-
- name: Create Pull Request with GitHub CLI
56-
if: steps.check_changes.outputs.changes_detected == 'true'
57-
run: |
58-
gh pr create \
59-
--base main \
60-
--head ${{ steps.setup_cli.outputs.branch_name }} \
61-
--title "Update OpenAPI Specification" \
62-
--body "This PR updates the OpenAPI specification from the official Vapi API endpoint.
63-
64-
- Auto-generated by the Update OpenAPI Specification workflow
65-
- Source: https://api.vapi.ai/api-json
66-
- Generated at: $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
67-
env:
68-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69-
70-
- name: PR Result
71-
if: steps.check_changes.outputs.changes_detected == 'true'
72-
run: |
73-
echo "Pull request created successfully!"
74-
75-
- name: No Changes Result
76-
if: steps.check_changes.outputs.changes_detected == 'false'
77-
run: |
78-
echo "No changes detected in OpenAPI specification. No PR created."
15+
- uses: actions/checkout@v4
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
- name: Update OpenAPI Spec
19+
uses: fern-api/sync-openapi@v2
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
branch: 'update-openapi-spec'
23+
update_from_source: true
24+
add_timestamp: true

0 commit comments

Comments
 (0)