Skip to content

Commit dedca17

Browse files
authored
Update doc-sync (#1763)
1 parent 3314f23 commit dedca17

File tree

1 file changed

+53
-13
lines changed

1 file changed

+53
-13
lines changed

.github/workflows/docs-sync.yml

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run: |
3636
# Check if changes require documentation updates
3737
NEEDS_DOCS_UPDATE=false
38-
38+
3939
# Define patterns that typically require docs updates
4040
DOCS_PATTERNS=(
4141
"^src/.*\.ts$"
@@ -49,7 +49,7 @@ jobs:
4949
"^api/"
5050
"^schema/"
5151
)
52-
52+
5353
while IFS= read -r file; do
5454
for pattern in "${DOCS_PATTERNS[@]}"; do
5555
if [[ $file =~ $pattern ]]; then
@@ -58,7 +58,7 @@ jobs:
5858
fi
5959
done
6060
done <<< "${{ steps.changed-files.outputs.changed_files }}"
61-
61+
6262
echo "needs_update=$NEEDS_DOCS_UPDATE" >> $GITHUB_OUTPUT
6363
echo "Files that may need docs updates: ${{ steps.changed-files.outputs.changed_files }}"
6464
@@ -70,13 +70,13 @@ jobs:
7070
token: ${{ secrets.CREATE_PR_TOKEN }}
7171
path: docs-repo
7272

73-
- name: Analyze changes and create docs PR
73+
- name: Analyze changes and update docs
7474
if: steps.check-docs.outputs.needs_update == 'true'
7575
uses: anthropics/claude-code-action@beta
7676
with:
7777
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
7878
direct_prompt: |
79-
I need you to analyze the changes in this controller repository PR and determine if the documentation in the cartridge-gg/docs repository needs to be updated.
79+
I need you to analyze the changes in this controller repository PR and update the documentation in the cartridge-gg/docs repository accordingly.
8080
8181
**PR Information:**
8282
- Title: ${{ github.event.pull_request.title }}
@@ -88,25 +88,65 @@ jobs:
8888
2. Check the docs-repo directory to see what documentation currently exists
8989
3. Determine if any existing documentation needs updates or if new documentation should be created
9090
4. If updates are needed:
91-
- Create or update the appropriate documentation files
91+
- Create or update the appropriate documentation files in the docs-repo directory
9292
- Ensure the documentation accurately reflects the current state of the controller
9393
- Follow the existing documentation style and structure
94-
- Create a new branch in the docs repo
95-
- Commit the changes with a descriptive message
96-
- Create a pull request in the docs repository
94+
- Focus on user-facing changes, API changes, new features, or breaking changes
9795
9896
**Important guidelines:**
9997
- Only create documentation updates if they are actually needed
100-
- Focus on user-facing changes, API changes, new features, or breaking changes
10198
- Don't document internal implementation details unless they affect usage
10299
- If no documentation updates are needed, simply state that and exit
100+
- DO NOT create git branches, commits, or PRs - just update the files
101+
102+
The docs repository is checked out in the `docs-repo` directory. Please analyze the controller changes and update the documentation files accordingly.
103+
104+
allowed_tools: "Read,Write,Edit,MultiEdit,Glob,Grep"
105+
106+
- name: Create branch and commit changes
107+
if: steps.check-docs.outputs.needs_update == 'true'
108+
working-directory: docs-repo
109+
run: |
110+
# Configure git
111+
git config user.name "github-actions[bot]"
112+
git config user.email "github-actions[bot]@users.noreply.github.com"
113+
114+
# Check if there are any changes
115+
if [ -n "$(git status --porcelain)" ]; then
116+
# Create new branch
117+
BRANCH_NAME="docs-update-$(date +%s)"
118+
git checkout -b "$BRANCH_NAME"
119+
120+
# Add and commit changes
121+
git add .
122+
git commit -m "docs: Update documentation for controller PR #${{ github.event.pull_request.number }}
103123
104-
The docs repository is checked out in the `docs-repo` directory. Please analyze the controller changes and update the documentation accordingly.
124+
Updates documentation to reflect changes made in:
125+
${{ github.event.pull_request.title }}
126+
127+
Related controller PR: cartridge-gg/controller#${{ github.event.pull_request.number }}"
128+
129+
# Push branch
130+
git push origin "$BRANCH_NAME"
131+
132+
# Create PR
133+
gh pr create \
134+
--title "docs: Update documentation for controller PR #${{ github.event.pull_request.number }}" \
135+
--body "This PR updates the documentation to reflect changes made in cartridge-gg/controller#${{ github.event.pull_request.number }}
136+
137+
**Original PR Details:**
138+
- Title: ${{ github.event.pull_request.title }}
139+
- Files changed: ${{ steps.changed-files.outputs.changed_files }}
105140
106-
allowed_tools: "Bash(git *),Bash(cd *),Read,Write,Edit,MultiEdit,Glob,Grep"
141+
Please review the documentation changes to ensure they accurately reflect the controller updates."
142+
else
143+
echo "No documentation changes were made by Claude"
144+
fi
145+
env:
146+
GITHUB_TOKEN: ${{ secrets.CREATE_PR_TOKEN }}
107147

108148
- name: Cleanup
109149
if: always()
110150
run: |
111151
# Clean up any temporary files or directories
112-
rm -rf docs-repo || true
152+
rm -rf docs-repo || true

0 commit comments

Comments
 (0)