Skip to content

Commit da5f120

Browse files
docs: handle PR permission restrictions in sync workflow (#161)
* docs: handle PR permission restrictions in sync workflow * docs: use GitHub App token for sdk sync PRs
1 parent 62e0c67 commit da5f120

2 files changed

Lines changed: 47 additions & 124 deletions

File tree

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

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ on:
2929
schedule:
3030
- cron: "*/15 * * * *"
3131

32+
permissions:
33+
contents: write
34+
pull-requests: write
35+
3236
# prevent concurrent runs that could conflict
3337
concurrency:
3438
group: sdk-reference-${{ github.ref }}
@@ -38,14 +42,19 @@ jobs:
3842
generate:
3943
runs-on: ubuntu-latest
4044
timeout-minutes: 30
41-
permissions:
42-
contents: write
43-
pull-requests: write
4445

4546
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+
4654
- name: Checkout docs repo
47-
uses: actions/checkout@v4
55+
uses: actions/checkout@v6
4856
with:
57+
token: ${{ steps.app-token.outputs.token }}
4958
fetch-depth: 0
5059

5160
- name: Setup Node.js
@@ -133,21 +142,38 @@ jobs:
133142
- name: Commit changes and manage pull request
134143
if: steps.changes.outputs.changes == 'true'
135144
id: pr
136-
env:
137-
GH_TOKEN: ${{ github.token }}
138-
BASE_BRANCH: ${{ github.ref_name }}
139-
BRANCH_NAME: automation/sdk-reference-sync
140-
TRIGGER: ${{ steps.params.outputs.trigger }}
141-
SDK_NAME: ${{ steps.params.outputs.sdk }}
142-
SDK_VERSION: ${{ steps.params.outputs.version }}
143-
LIMIT_DISPLAY: ${{ steps.params.outputs.limit_display }}
144-
FORCE: ${{ steps.params.outputs.force }}
145-
CHANGED_FILES: ${{ steps.changes.outputs.changed_files }}
146-
TOTAL_MDX_FILES: ${{ steps.changes.outputs.total_mdx_files }}
147-
WORKFLOW_NAME: ${{ github.workflow }}
148-
REPOSITORY: ${{ github.repository }}
149-
RUN_ID: ${{ github.run_id }}
150-
run: bash scripts/create-sdk-reference-sync-pr.sh
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 }}
151177
152178
- name: Summary
153179
env:
@@ -159,8 +185,8 @@ jobs:
159185
CHANGES: ${{ steps.changes.outputs.changes }}
160186
CHANGED_FILES: ${{ steps.changes.outputs.changed_files }}
161187
TOTAL_MDX_FILES: ${{ steps.changes.outputs.total_mdx_files }}
162-
PR_OPERATION: ${{ steps.pr.outputs.operation }}
163-
PR_URL: ${{ steps.pr.outputs.url }}
188+
PR_OPERATION: ${{ steps.pr.outputs.pull-request-operation }}
189+
PR_URL: ${{ steps.pr.outputs.pull-request-url }}
164190
run: |
165191
echo "## SDK Reference Generation Complete" >> $GITHUB_STEP_SUMMARY
166192
echo "" >> $GITHUB_STEP_SUMMARY

scripts/create-sdk-reference-sync-pr.sh

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)