2626
2727 repository_dispatch :
2828 types : [sdk-release]
29+ schedule :
30+ - cron : " */15 * * * *"
2931
3032# prevent concurrent runs that could conflict
3133concurrency :
3840 timeout-minutes : 30
3941 permissions :
4042 contents : write
43+ pull-requests : write
4144
4245 steps :
4346 - name : Checkout docs repo
7881 - name : Install Python dependencies
7982 run : pip install -r requirements.txt
8083
81- - name : Determine SDK and Version
84+ - name : Determine sync parameters
8285 id : params
8386 env :
8487 EVENT_NAME : ${{ github.event_name }}
@@ -91,20 +94,42 @@ jobs:
9194 PAYLOAD_LIMIT : ${{ github.event.client_payload.limit }}
9295 run : |
9396 if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
97+ TRIGGER="workflow_dispatch"
9498 SDK="$INPUT_SDK"
9599 VERSION="$INPUT_VERSION"
96100 LIMIT="$INPUT_LIMIT"
97101 FORCE="$INPUT_FORCE"
98102 elif [[ "$EVENT_NAME" == "repository_dispatch" ]]; then
103+ TRIGGER="repository_dispatch (sdk-release)"
99104 SDK="$PAYLOAD_SDK"
100105 VERSION="${PAYLOAD_VERSION:-latest}"
101106 LIMIT="${PAYLOAD_LIMIT:-5}"
102107 FORCE="false"
108+ elif [[ "$EVENT_NAME" == "schedule" ]]; then
109+ TRIGGER="schedule (*/15 * * * *)"
110+ SDK="all"
111+ VERSION="all"
112+ LIMIT="3"
113+ FORCE="false"
114+ else
115+ TRIGGER="$EVENT_NAME"
116+ SDK="all"
117+ VERSION="latest"
118+ LIMIT="5"
119+ FORCE="false"
103120 fi
104121
122+ if [[ -z "$LIMIT" || "$LIMIT" == "0" ]]; then
123+ LIMIT_DISPLAY="No limit"
124+ else
125+ LIMIT_DISPLAY="$LIMIT"
126+ fi
127+
128+ echo "trigger=$TRIGGER" >> $GITHUB_OUTPUT
105129 echo "sdk=${SDK:-all}" >> $GITHUB_OUTPUT
106130 echo "version=${VERSION:-latest}" >> $GITHUB_OUTPUT
107131 echo "limit=${LIMIT:-5}" >> $GITHUB_OUTPUT
132+ echo "limit_display=$LIMIT_DISPLAY" >> $GITHUB_OUTPUT
108133 echo "force=${FORCE:-false}" >> $GITHUB_OUTPUT
109134
110135 - name : Generate SDK Reference
@@ -128,47 +153,96 @@ jobs:
128153
129154 pnpm run generate $ARGS
130155
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 }}
156+ - name : Collect change details
157+ id : changes
136158 run : |
137- git config user.name "github-actions[bot] "
138- git config user.email "github-actions[bot]@users.noreply.github.com "
159+ CHANGED_FILES="$( git status --porcelain -- docs/sdk-reference docs.json | wc -l | tr -d ' ') "
160+ TOTAL_MDX_FILES="$(find docs/sdk-reference -type f -name '*.mdx' | wc -l | tr -d ' ') "
139161
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"
162+ if [[ "$CHANGED_FILES" == "0" ]]; then
145163 echo "changes=false" >> $GITHUB_OUTPUT
146164 else
147- git commit -m "docs: update SDK reference for $SDK_NAME $SDK_VERSION"
148- git push
149165 echo "changes=true" >> $GITHUB_OUTPUT
150166 fi
151167
168+ echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT
169+ echo "total_mdx_files=$TOTAL_MDX_FILES" >> $GITHUB_OUTPUT
170+
171+ - name : Create pull request
172+ if : steps.changes.outputs.changes == 'true'
173+ id : cpr
174+ uses : peter-evans/create-pull-request@v8
175+ with :
176+ branch : automation/sdk-reference-sync
177+ delete-branch : true
178+ add-paths : |
179+ docs/sdk-reference
180+ docs.json
181+ author : github-actions[bot] <github-actions[bot]@users.noreply.github.com>
182+ committer : github-actions[bot] <github-actions[bot]@users.noreply.github.com>
183+ commit-message : docs: sync SDK reference for ${{ steps.params.outputs.sdk }} ${{ steps.params.outputs.version }}
184+ title : docs: sync SDK reference for ${{ steps.params.outputs.sdk }} ${{ steps.params.outputs.version }}
185+ body : |
186+ ## Summary
187+ This automated PR syncs generated SDK reference documentation.
188+
189+ ## Trigger
190+ - Source: `${{ steps.params.outputs.trigger }}`
191+ - SDK: `${{ steps.params.outputs.sdk }}`
192+ - Version: `${{ steps.params.outputs.version }}`
193+ - Limit: `${{ steps.params.outputs.limit_display }}`
194+ - Force: `${{ steps.params.outputs.force }}`
195+
196+ ## Changes
197+ - Updates generated reference files under `docs/sdk-reference/**`
198+ - Updates `docs.json` navigation when generation changes the docs tree
199+ - Changed files detected in this run: `${{ steps.changes.outputs.changed_files }}`
200+ - Total tracked MDX reference files after generation: `${{ steps.changes.outputs.total_mdx_files }}`
201+
202+ ## Validation
203+ - [x] SDK reference generator completed successfully
204+ - [x] Workflow run summary is attached to this run
205+ - [ ] Reviewer has verified the generated docs diff before merge
206+
207+ ## Run Details
208+ - Workflow: `${{ github.workflow }}`
209+ - Run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
210+
152211 - name : Summary
153212 env :
213+ TRIGGER : ${{ steps.params.outputs.trigger }}
154214 SDK_NAME : ${{ steps.params.outputs.sdk }}
155215 SDK_VERSION : ${{ steps.params.outputs.version }}
156- LIMIT : ${{ steps.params.outputs.limit }}
157- CHANGES : ${{ steps.commit.outputs.changes }}
216+ LIMIT : ${{ steps.params.outputs.limit_display }}
217+ FORCE : ${{ steps.params.outputs.force }}
218+ CHANGES : ${{ steps.changes.outputs.changes }}
219+ CHANGED_FILES : ${{ steps.changes.outputs.changed_files }}
220+ TOTAL_MDX_FILES : ${{ steps.changes.outputs.total_mdx_files }}
221+ PR_OPERATION : ${{ steps.cpr.outputs.pull-request-operation }}
222+ PR_URL : ${{ steps.cpr.outputs.pull-request-url }}
158223 run : |
159224 echo "## SDK Reference Generation Complete" >> $GITHUB_STEP_SUMMARY
160225 echo "" >> $GITHUB_STEP_SUMMARY
161226 echo "| Parameter | Value |" >> $GITHUB_STEP_SUMMARY
162227 echo "|-----------|-------|" >> $GITHUB_STEP_SUMMARY
228+ echo "| Trigger | $TRIGGER |" >> $GITHUB_STEP_SUMMARY
163229 echo "| SDK | $SDK_NAME |" >> $GITHUB_STEP_SUMMARY
164230 echo "| Version | $SDK_VERSION |" >> $GITHUB_STEP_SUMMARY
165- echo "| Limit | ${LIMIT:-No limit} |" >> $GITHUB_STEP_SUMMARY
166- echo "| Changes committed | $CHANGES |" >> $GITHUB_STEP_SUMMARY
231+ echo "| Limit | $LIMIT |" >> $GITHUB_STEP_SUMMARY
232+ echo "| Force | $FORCE |" >> $GITHUB_STEP_SUMMARY
233+ echo "| Changes detected | $CHANGES |" >> $GITHUB_STEP_SUMMARY
234+ echo "| Changed files | ${CHANGED_FILES:-0} |" >> $GITHUB_STEP_SUMMARY
235+ echo "| PR operation | ${PR_OPERATION:-No PR created} |" >> $GITHUB_STEP_SUMMARY
236+ if [[ -n "$PR_URL" ]]; then
237+ echo "| Pull request | $PR_URL |" >> $GITHUB_STEP_SUMMARY
238+ fi
167239 echo "" >> $GITHUB_STEP_SUMMARY
168240
169241 if [[ "$CHANGES" == "true" ]]; then
170242 echo "### Generated Files" >> $GITHUB_STEP_SUMMARY
171243 echo '```' >> $GITHUB_STEP_SUMMARY
172- echo "Total MDX files: $(find docs/sdk-reference -type f -name '*.mdx' | wc -l) " >> $GITHUB_STEP_SUMMARY
244+ echo "Total MDX files: $TOTAL_MDX_FILES " >> $GITHUB_STEP_SUMMARY
173245 echo '```' >> $GITHUB_STEP_SUMMARY
246+ else
247+ echo "No SDK reference changes were detected, so no pull request was created." >> $GITHUB_STEP_SUMMARY
174248 fi
0 commit comments