1- name : Intelligent Documentation Sync with Claude Code
1+ name : Documentation Sync with Claude Code
22
33on :
44 pull_request :
77jobs :
88 sync-docs :
99 runs-on : ubuntu-latest
10+ permissions :
11+ contents : write
12+ pull-requests : write
13+ id-token : write
1014 steps :
1115 - name : Checkout source repository
1216 uses : actions/checkout@v4
5761
5862 - name : Create prompt for Claude Code
5963 if : steps.get-diffs.outputs.skip != 'true'
64+ id : create-prompt
6065 run : |
6166 cat > /tmp/claude_prompt.md << EOF
6267 # Intelligent Documentation Sync Task
@@ -98,20 +103,68 @@ jobs:
98103
99104 **Step 2: If Documentation Sync is Needed**
100105
101- If you determine documentation updates are required, please:
102- 1. Navigate to the ./cloudflare-docs directory
103- 2. Adapt the relevant changes for the cloudflare-docs repository structure and style
106+ If you determine documentation updates are required, YOU MUST COMPLETE ALL STEPS:
107+
108+ 1. Navigate to ./cloudflare-docs (already cloned, branch sync-docs-pr-${{ github.event.pull_request.number }} checked out)
109+ 2. Adapt changes for cloudflare-docs repository structure and style
104110 3. Create or update the appropriate markdown files
105- 4. Ensure content follows cloudflare-docs conventions and formatting
106- 5. Commit with message: "Sync docs from PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}"
107- 6. Push the branch to origin
108- 7. Create a PR in cloudflare-docs using gh CLI:
109- - Title: "📚 Sync docs from ${{ github.repository }}#${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}"
110- - Body should include:
111- * Explanation this is AI-adapted documentation sync
112- * Link to original PR: https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}
113- * Summary of what documentation changes were made
114- * Note that it should be reviewed alongside the source PR
111+ 4. Ensure content follows cloudflare-docs conventions
112+
113+ 5. **CRITICAL - Commit changes:**
114+ Run: `cd cloudflare-docs && git add . && git commit -m "Sync docs from PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}"`
115+
116+ 6. **CRITICAL - Push to remote:**
117+ Run: `cd cloudflare-docs && git push origin sync-docs-pr-${{ github.event.pull_request.number }}`
118+
119+ 7. **CRITICAL - Create PR in cloudflare-docs:**
120+ Run: `gh pr create --repo cloudflare/cloudflare-docs --base main --head sync-docs-pr-${{ github.event.pull_request.number }} --title "📚 Sync docs from ${{ github.repository }}#${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}" --body "🤖 Automated sync from https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"`
121+
122+ 8. **CRITICAL - Comment on original PR (or edit existing comment):**
123+ Get the docs PR URL, then create or update comment:
124+ ```bash
125+ DOCS_PR_URL=$(gh pr list --repo cloudflare/cloudflare-docs --head sync-docs-pr-${{ github.event.pull_request.number }} --json url --jq '.[0].url')
126+
127+ # Check if bot comment already exists (look for comments from github-actions bot containing "Documentation sync")
128+ EXISTING_COMMENT_ID=$(gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json comments --jq '.comments[] | select(.author.login == "github-actions" and (.body | contains("Documentation sync"))) | .id' | head -1)
129+
130+ COMMENT_BODY="📚 **Documentation sync PR:** $DOCS_PR_URL\n\n_This comment will be updated as the PR changes._"
131+
132+ if [ -n "$EXISTING_COMMENT_ID" ]; then
133+ # Edit existing comment
134+ gh api --method PATCH /repos/${{ github.repository }}/issues/comments/$EXISTING_COMMENT_ID -f body="$COMMENT_BODY"
135+ else
136+ # Create new comment
137+ gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "$COMMENT_BODY"
138+ fi
139+ ```
140+
141+ ⚠️ THE TASK IS NOT COMPLETE UNTIL ALL 8 STEPS ARE DONE. Do not stop after editing files.
142+
143+ ## Documentation Writing Guidelines (Diátaxis Framework)
144+
145+ When writing the documentation content, adapt your approach based on what changed:
146+
147+ **For a single function/method:**
148+ - **Reference**: Technical description - signature, parameters, return types, behavior
149+ - **Example**: Concise code snippet showing usage in context
150+ - **Use cases**: Brief bullets on when/why to use it (if not obvious)
151+ - **DO NOT** create separate "how-to" sections - integrate examples into the reference
152+
153+ **For new features/workflows (multiple related functions):**
154+ - **Reference**: Complete API docs for all functions
155+ - **How-to guide**: Step-by-step guide for real-world tasks
156+ - **Explanation**: Architecture, design decisions, alternatives
157+
158+ **For breaking changes:**
159+ - **Reference**: Updated API documentation
160+ - **How-to**: Migration guide (before/after)
161+ - **Explanation**: Why changed, implications
162+
163+ **Key principles:**
164+ - Single functions = reference + example (concise)
165+ - Multi-step workflows = separate how-to guides
166+ - Keep reference neutral and factual
167+ - Don't overexplain simple functions
115168
116169 **Step 3: Provide Clear Output**
117170
@@ -128,11 +181,17 @@ jobs:
128181 Begin your evaluation now.
129182 EOF
130183
184+ echo "prompt<<PROMPT_EOF" >> $GITHUB_OUTPUT
185+ cat /tmp/claude_prompt.md >> $GITHUB_OUTPUT
186+ echo "PROMPT_EOF" >> $GITHUB_OUTPUT
187+
131188 - name : Run Claude Code to create adapted PR
132189 if : steps.get-diffs.outputs.skip != 'true'
133190 uses : anthropics/claude-code-action@v1
134191 with :
135192 anthropic_api_key : ${{ secrets.ANTHROPIC_API_KEY }}
136- prompt_file : /tmp/claude_prompt.md
193+ github_token : ${{ secrets.GITHUB_TOKEN }}
194+ prompt : ${{ steps.create-prompt.outputs.prompt }}
195+ claude_args : " --allowed-tools Bash,Edit"
137196 env :
138197 GH_TOKEN : ${{ secrets.AGENTS_GITHUB_TOKEN }}
0 commit comments