@@ -33,34 +33,33 @@ jobs:
3333 run : |
3434 set -e
3535 if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
36- # Get changed files for the specified commit
3736 git fetch origin
38- CHANGED_FILES=$(git diff --name-only ${{ github.event.inputs.commit_sha }}~1 ${{ github.event.inputs.commit_sha }})
37+ DIFF_BASE="${{ github.event.inputs.commit_sha }}~1"
38+ DIFF_HEAD="${{ github.event.inputs.commit_sha }}"
3939 else
40- # Get list of changed files in the merged PR
4140 git fetch origin main
42- CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.merge_commit_sha }})
41+ DIFF_BASE="${{ github.event.pull_request.base.sha }}"
42+ DIFF_HEAD="${{ github.event.pull_request.merge_commit_sha }}"
4343 fi
44+ CHANGED_FILES=$(git diff --name-only "$DIFF_BASE" "$DIFF_HEAD")
45+ # Truncate diff to avoid blowing up the prompt
46+ DIFF_CONTENT=$(git diff "$DIFF_BASE" "$DIFF_HEAD" -- '*.ts' '*.tsx' '*.md' | head -c 60000)
4447 echo "changed_files<<EOF" >> $GITHUB_OUTPUT
4548 echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
4649 echo "EOF" >> $GITHUB_OUTPUT
50+ echo "diff_content<<EOF" >> $GITHUB_OUTPUT
51+ echo "$DIFF_CONTENT" >> $GITHUB_OUTPUT
52+ echo "EOF" >> $GITHUB_OUTPUT
4753
4854 - name : Check if docs update needed
4955 id : check-docs
5056 run : |
51- # Check if changes require documentation updates
5257 NEEDS_DOCS_UPDATE=false
5358
54- # Define patterns that typically require docs updates
5559 DOCS_PATTERNS=(
56- "^src/.*\.ts$"
57- "^src/.*\.tsx$"
5860 "^packages/.*/src/.*\.ts$"
5961 "^packages/.*/src/.*\.tsx$"
60- "^README\.md$"
61- "^CHANGELOG\.md$"
6262 "^docs/"
63- "package\.json$"
6463 "^api/"
6564 "^schema/"
6665 )
@@ -90,71 +89,76 @@ jobs:
9089 uses : anthropics/claude-code-action@beta
9190 with :
9291 anthropic_api_key : ${{ secrets.ANTHROPIC_API_KEY }}
92+ model : " claude-sonnet-4-5-20250929"
9393 direct_prompt : |
94- I need you to analyze the changes in this controller repository PR and update the documentation in the cartridge-gg/docs repository accordingly.
94+ Analyze changes in this controller repository and update documentation
95+ in the cartridge-gg/docs repository ONLY if user-facing behavior changed.
9596
9697 **Change Information:**
9798 - Title: ${{ github.event.pull_request.title || format('Manual trigger for commit {0}', github.event.inputs.commit_sha) }}
9899 - Description: ${{ github.event.pull_request.body || 'Manually triggered documentation sync' }}
99100 - Files changed: ${{ steps.changed-files.outputs.changed_files }}
100101 - Commit SHA: ${{ github.event.pull_request.merge_commit_sha || github.event.inputs.commit_sha }}
101102
102- **Your tasks:**
103- 1. Review the changed files and PR description to understand what functionality was added, modified, or removed
104- 2. Check the docs-repo directory to see what documentation currently exists
105- 3. Determine if any existing documentation needs updates or if new documentation should be created
106- 4. If updates are needed:
107- - Create or update the appropriate documentation files in the docs-repo directory
108- - Ensure the documentation accurately reflects the current state of the controller
109- - Follow the existing documentation style and structure
110- - Focus on user-facing changes, API changes, new features, or breaking changes
111-
112- **Important guidelines:**
113- - Only create documentation updates if they are actually needed
114- - Don't document internal implementation details unless they affect usage
115- - If no documentation updates are needed, simply state that and exit
116- - DO NOT create git branches, commits, or PRs - just update the files
117-
118- The docs repository is checked out in the `docs-repo` directory. Please analyze the controller changes and update the documentation files accordingly.
103+ **Diff of user-facing files:**
104+ ${{ steps.changed-files.outputs.diff_content }}
105+
106+ **Docs repo structure** (checked out in `docs-repo/`):
107+ The site uses Vocs. Content lives in `docs-repo/src/pages/` with three sections:
108+ - `controller/` — wallet, sessions, policies, presets, achievements, inventory, native integrations, examples
109+ - `slot/` — Katana/Torii deployment, billing, scale, paymaster, vRNG, RPC
110+ - `arcade/` — game hub setup, marketplace
111+ Sidebar config is in `docs-repo/vocs.config.ts`.
112+
113+ **Rules — read these carefully:**
114+ 1. DEFAULT TO NO CHANGES. Most code PRs do not need docs updates.
115+ Internal refactors, test changes, CI changes, and dependency bumps need nothing.
116+ Only proceed if there is a concrete user-facing change (new API, changed behavior,
117+ new feature, removed feature, changed configuration).
118+ 2. SINGLE CANONICAL LOCATION. Each piece of information belongs on exactly one page.
119+ Find the one page that owns the topic and make your substantive edits there.
120+ Other pages MAY add a brief cross-reference linking to the canonical page,
121+ but do NOT duplicate explanations, code samples, or configuration details
122+ across multiple pages.
123+ 3. MINIMAL EDITS. Update only the specific section affected. Do not rewrite
124+ surrounding paragraphs, add new sections for context, or reorganize existing content.
125+ 4. ONE CODE EXAMPLE per concept. If a code sample is needed, add it once in the
126+ canonical location. Do not add the same or similar examples to multiple pages.
127+ 5. Do NOT create git branches, commits, or PRs — just update files.
128+ 6. If no documentation updates are needed, state that clearly and exit.
119129
120130 allowed_tools : " Read,Write,Edit,MultiEdit,Glob,Grep"
121131
122132 - name : Create branch and commit changes
123133 if : steps.check-docs.outputs.needs_update == 'true'
124134 working-directory : docs-repo
125135 run : |
126- # Configure git
127136 git config user.name "github-actions[bot]"
128137 git config user.email "github-actions[bot]@users.noreply.github.com"
129138
130- # Check if there are any changes
131139 if [ -n "$(git status --porcelain)" ]; then
132- # Create new branch
133140 BRANCH_NAME="docs-update-$(date +%s)"
134141 git checkout -b "$BRANCH_NAME"
135-
136- # Add and commit changes
142+
137143 git add .
138144 if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
139145 git commit -m "docs: Update documentation for controller commit ${{ github.event.inputs.commit_sha }}
140146
141147 Updates documentation to reflect changes made in commit:
142148 ${{ github.event.inputs.commit_sha }}
143-
149+
144150 Manually triggered documentation sync"
145151 else
146152 git commit -m "docs: Update documentation for controller PR #${{ github.event.pull_request.number }}
147153
148154 Updates documentation to reflect changes made in:
149155 ${{ github.event.pull_request.title }}
150-
156+
151157 Related controller PR: cartridge-gg/controller#${{ github.event.pull_request.number }}"
152158 fi
153-
154- # Push branch
159+
155160 git push origin "$BRANCH_NAME"
156-
157- # Create PR
161+
158162 if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
159163 gh pr create \
160164 --title "docs: Update documentation for controller commit ${{ github.event.inputs.commit_sha }}" \
@@ -166,6 +170,7 @@ jobs:
166170 - Trigger: Manual documentation sync
167171
168172 Please review the documentation changes to ensure they accurately reflect the controller updates."
173+ gh pr merge --auto --squash
169174 else
170175 gh pr create \
171176 --title "docs: Update documentation for controller PR #${{ github.event.pull_request.number }}" \
@@ -176,6 +181,7 @@ jobs:
176181 - Files changed: ${{ steps.changed-files.outputs.changed_files }}
177182
178183 Please review the documentation changes to ensure they accurately reflect the controller updates."
184+ gh pr merge --auto --squash
179185 fi
180186 else
181187 echo "No documentation changes were made by Claude"
@@ -186,5 +192,4 @@ jobs:
186192 - name : Cleanup
187193 if : always()
188194 run : |
189- # Clean up any temporary files or directories
190195 rm -rf docs-repo || true
0 commit comments