Skip to content

Commit 1db8c61

Browse files
authored
Merge branch 'main' into add-api-ref-to-nav
2 parents d9425ca + 2f7a1d8 commit 1db8c61

6 files changed

Lines changed: 1072 additions & 43 deletions

File tree

.github/workflows/sdk-reference-generator-test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
pull_request:
55
paths:
66
- "sdk-reference-generator/**"
7+
- ".github/workflows/sdk-reference-sync.yml"
8+
- ".github/workflows/sdk-reference-generator-test.yml"
9+
- "requirements.txt"
10+
- "docs.json"
11+
- "docs/sdk-reference/**"
712

813
jobs:
914
test:

.github/workflows/sdk-reference-sync.yml

Lines changed: 81 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ on:
2626

2727
repository_dispatch:
2828
types: [sdk-release]
29+
schedule:
30+
- cron: "*/15 * * * *"
31+
32+
permissions:
33+
contents: write
34+
pull-requests: write
2935

3036
# prevent concurrent runs that could conflict
3137
concurrency:
@@ -36,13 +42,19 @@ jobs:
3642
generate:
3743
runs-on: ubuntu-latest
3844
timeout-minutes: 30
39-
permissions:
40-
contents: write
4145

4246
steps:
47+
- name: Generate GitHub App installation token
48+
id: app-token
49+
uses: actions/create-github-app-token@v2
50+
with:
51+
app-id: ${{ vars.AUTOFIXER_APP_ID }}
52+
private-key: ${{ secrets.AUTOFIXER_APP_SECRET }}
53+
4354
- name: Checkout docs repo
44-
uses: actions/checkout@v4
55+
uses: actions/checkout@v6
4556
with:
57+
token: ${{ steps.app-token.outputs.token }}
4658
fetch-depth: 0
4759

4860
- name: Setup Node.js
@@ -78,7 +90,7 @@ jobs:
7890
- name: Install Python dependencies
7991
run: pip install -r requirements.txt
8092

81-
- name: Determine SDK and Version
93+
- name: Resolve generation inputs from trigger
8294
id: params
8395
env:
8496
EVENT_NAME: ${{ github.event_name }}
@@ -89,23 +101,7 @@ jobs:
89101
PAYLOAD_SDK: ${{ github.event.client_payload.sdk }}
90102
PAYLOAD_VERSION: ${{ github.event.client_payload.version }}
91103
PAYLOAD_LIMIT: ${{ github.event.client_payload.limit }}
92-
run: |
93-
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
94-
SDK="$INPUT_SDK"
95-
VERSION="$INPUT_VERSION"
96-
LIMIT="$INPUT_LIMIT"
97-
FORCE="$INPUT_FORCE"
98-
elif [[ "$EVENT_NAME" == "repository_dispatch" ]]; then
99-
SDK="$PAYLOAD_SDK"
100-
VERSION="${PAYLOAD_VERSION:-latest}"
101-
LIMIT="${PAYLOAD_LIMIT:-5}"
102-
FORCE="false"
103-
fi
104-
105-
echo "sdk=${SDK:-all}" >> $GITHUB_OUTPUT
106-
echo "version=${VERSION:-latest}" >> $GITHUB_OUTPUT
107-
echo "limit=${LIMIT:-5}" >> $GITHUB_OUTPUT
108-
echo "force=${FORCE:-false}" >> $GITHUB_OUTPUT
104+
run: bash scripts/resolve-sdk-reference-sync-params.sh
109105

110106
- name: Generate SDK Reference
111107
working-directory: sdk-reference-generator
@@ -128,47 +124,92 @@ jobs:
128124
129125
pnpm run generate $ARGS
130126
131-
- name: Commit and push changes
132-
id: commit
133-
env:
134-
SDK_NAME: ${{ steps.params.outputs.sdk }}
135-
SDK_VERSION: ${{ steps.params.outputs.version }}
127+
- name: Collect change details
128+
id: changes
136129
run: |
137-
git config user.name "github-actions[bot]"
138-
git config user.email "github-actions[bot]@users.noreply.github.com"
130+
CHANGED_FILES="$(git status --porcelain -- docs/sdk-reference docs.json | wc -l | tr -d ' ')"
131+
TOTAL_MDX_FILES="$(find docs/sdk-reference -type f -name '*.mdx' | wc -l | tr -d ' ')"
139132
140-
git add docs/sdk-reference/
141-
git add docs.json
142-
143-
if git diff --staged --quiet; then
144-
echo "No changes to commit"
133+
if [[ "$CHANGED_FILES" == "0" ]]; then
145134
echo "changes=false" >> $GITHUB_OUTPUT
146135
else
147-
git commit -m "docs: update SDK reference for $SDK_NAME $SDK_VERSION"
148-
git push
149136
echo "changes=true" >> $GITHUB_OUTPUT
150137
fi
151138
139+
echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT
140+
echo "total_mdx_files=$TOTAL_MDX_FILES" >> $GITHUB_OUTPUT
141+
142+
- name: Commit changes and manage pull request
143+
if: steps.changes.outputs.changes == 'true'
144+
id: pr
145+
uses: peter-evans/create-pull-request@v7
146+
with:
147+
token: ${{ steps.app-token.outputs.token }}
148+
branch: automation/sdk-reference-sync
149+
delete-branch: true
150+
add-paths: |
151+
docs/sdk-reference
152+
docs.json
153+
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
154+
committer: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
155+
commit-message: "docs: sync SDK reference for ${{ steps.params.outputs.sdk }} ${{ steps.params.outputs.version }}"
156+
title: "docs: sync SDK reference for ${{ steps.params.outputs.sdk }} ${{ steps.params.outputs.version }}"
157+
body: |
158+
## Summary
159+
This automated PR syncs generated SDK reference documentation.
160+
161+
## Trigger
162+
- Source: `${{ steps.params.outputs.trigger }}`
163+
- SDK: `${{ steps.params.outputs.sdk }}`
164+
- Version: `${{ steps.params.outputs.version }}`
165+
- Limit: `${{ steps.params.outputs.limit_display }}`
166+
- Force: `${{ steps.params.outputs.force }}`
167+
168+
## Changes
169+
- Updates generated reference files under `docs/sdk-reference/**`
170+
- Updates `docs.json` navigation when generation changes the docs tree
171+
- Changed files detected in this run: `${{ steps.changes.outputs.changed_files }}`
172+
- Total tracked MDX reference files after generation: `${{ steps.changes.outputs.total_mdx_files }}`
173+
174+
## Run Details
175+
- Workflow: `${{ github.workflow }}`
176+
- Run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
177+
152178
- name: Summary
153179
env:
180+
TRIGGER: ${{ steps.params.outputs.trigger }}
154181
SDK_NAME: ${{ steps.params.outputs.sdk }}
155182
SDK_VERSION: ${{ steps.params.outputs.version }}
156-
LIMIT: ${{ steps.params.outputs.limit }}
157-
CHANGES: ${{ steps.commit.outputs.changes }}
183+
LIMIT: ${{ steps.params.outputs.limit_display }}
184+
FORCE: ${{ steps.params.outputs.force }}
185+
CHANGES: ${{ steps.changes.outputs.changes }}
186+
CHANGED_FILES: ${{ steps.changes.outputs.changed_files }}
187+
TOTAL_MDX_FILES: ${{ steps.changes.outputs.total_mdx_files }}
188+
PR_OPERATION: ${{ steps.pr.outputs.pull-request-operation }}
189+
PR_URL: ${{ steps.pr.outputs.pull-request-url }}
158190
run: |
159191
echo "## SDK Reference Generation Complete" >> $GITHUB_STEP_SUMMARY
160192
echo "" >> $GITHUB_STEP_SUMMARY
161193
echo "| Parameter | Value |" >> $GITHUB_STEP_SUMMARY
162194
echo "|-----------|-------|" >> $GITHUB_STEP_SUMMARY
195+
echo "| Trigger | $TRIGGER |" >> $GITHUB_STEP_SUMMARY
163196
echo "| SDK | $SDK_NAME |" >> $GITHUB_STEP_SUMMARY
164197
echo "| Version | $SDK_VERSION |" >> $GITHUB_STEP_SUMMARY
165-
echo "| Limit | ${LIMIT:-No limit} |" >> $GITHUB_STEP_SUMMARY
166-
echo "| Changes committed | $CHANGES |" >> $GITHUB_STEP_SUMMARY
198+
echo "| Limit | $LIMIT |" >> $GITHUB_STEP_SUMMARY
199+
echo "| Force | $FORCE |" >> $GITHUB_STEP_SUMMARY
200+
echo "| Changes detected | $CHANGES |" >> $GITHUB_STEP_SUMMARY
201+
echo "| Changed files | ${CHANGED_FILES:-0} |" >> $GITHUB_STEP_SUMMARY
202+
echo "| PR operation | ${PR_OPERATION:-No PR created} |" >> $GITHUB_STEP_SUMMARY
203+
if [[ -n "$PR_URL" ]]; then
204+
echo "| Pull request | $PR_URL |" >> $GITHUB_STEP_SUMMARY
205+
fi
167206
echo "" >> $GITHUB_STEP_SUMMARY
168207
169208
if [[ "$CHANGES" == "true" ]]; then
170209
echo "### Generated Files" >> $GITHUB_STEP_SUMMARY
171210
echo '```' >> $GITHUB_STEP_SUMMARY
172-
echo "Total MDX files: $(find docs/sdk-reference -type f -name '*.mdx' | wc -l)" >> $GITHUB_STEP_SUMMARY
211+
echo "Total MDX files: $TOTAL_MDX_FILES" >> $GITHUB_STEP_SUMMARY
173212
echo '```' >> $GITHUB_STEP_SUMMARY
213+
else
214+
echo "No SDK reference changes were detected, so no pull request was created." >> $GITHUB_STEP_SUMMARY
174215
fi

docs.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2479,8 +2479,15 @@
24792479
"icon": "python",
24802480
"versions": [
24812481
{
2482-
"version": "v2.4.1",
2482+
"version": "v2.5.0",
24832483
"default": true,
2484+
"pages": [
2485+
"docs/sdk-reference/code-interpreter-python-sdk/v2.5.0/code_interpreter"
2486+
]
2487+
},
2488+
{
2489+
"version": "v2.4.1",
2490+
"default": false,
24842491
"pages": [
24852492
"docs/sdk-reference/code-interpreter-python-sdk/v2.4.1/sandbox"
24862493
]

0 commit comments

Comments
 (0)