1- name : Documentation Sync
1+ name : doc-sync
22
33on :
44 pull_request :
77 workflow_dispatch :
88 inputs :
99 commit_sha :
10- description : ' Commit SHA to analyze for documentation updates'
10+ description : " Commit SHA to analyze for documentation updates"
1111 required : true
1212 type : string
1313
1414jobs :
1515 docs-sync :
16- if : github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
16+ if :
17+ github.event.pull_request.merged == true || github.event_name ==
18+ ' workflow_dispatch'
1719 runs-on : ubuntu-latest
1820 permissions :
1921 contents : read
@@ -28,17 +30,16 @@ jobs:
2830
2931 - name : Get changed files
3032 id : changed-files
31- env :
32- COMMIT_SHA : ${{ github.event.inputs.commit_sha }}
3333 run : |
34+ set -e
3435 if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
3536 # Get changed files for the specified commit
3637 git fetch origin
37- CHANGED_FILES=$(git diff --name-only "$COMMIT_SHA" ~1 "$COMMIT_SHA" )
38+ CHANGED_FILES=$(git diff --name-only ${{ github.event.inputs.commit_sha }} ~1 ${{ github.event.inputs.commit_sha }} )
3839 else
3940 # Get list of changed files in the merged PR
4041 git fetch origin main
41- CHANGED_FILES=$(git diff --name-only origin/main~1 origin/main )
42+ CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.merge_commit_sha }} )
4243 fi
4344 echo "changed_files<<EOF" >> $GITHUB_OUTPUT
4445 echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
7475 done <<< "${{ steps.changed-files.outputs.changed_files }}"
7576
7677 echo "needs_update=$NEEDS_DOCS_UPDATE" >> $GITHUB_OUTPUT
77- echo "Files that may need docs updates: ${{ steps.changed-files.outputs.changed_files }}"
78+ echo "Files that may need docs updates: $(echo '$ {{ steps.changed-files.outputs.changed_files }}' | tr '\n' ' ') "
7879
7980 - name : Checkout docs repository
8081 if : steps.check-docs.outputs.needs_update == 'true'
@@ -87,21 +88,16 @@ jobs:
8788 - name : Analyze changes and update docs
8889 if : steps.check-docs.outputs.needs_update == 'true'
8990 uses : anthropics/claude-code-action@beta
90- env :
91- PR_TITLE : ${{ github.event.pull_request.title }}
92- PR_BODY : ${{ github.event.pull_request.body }}
93- COMMIT_SHA : ${{ github.event.inputs.commit_sha }}
94- MERGE_COMMIT_SHA : ${{ github.event.pull_request.merge_commit_sha }}
9591 with :
9692 anthropic_api_key : ${{ secrets.ANTHROPIC_API_KEY }}
9793 direct_prompt : |
9894 I need you to analyze the changes in this controller repository PR and update the documentation in the cartridge-gg/docs repository accordingly.
9995
10096 **Change Information:**
101- - Title: ${{ env.PR_TITLE || format('Manual trigger for commit {0}', env.COMMIT_SHA ) }}
102- - Description: ${{ env.PR_BODY || 'Manually triggered documentation sync' }}
97+ - Title: ${{ github.event.pull_request.title || format('Manual trigger for commit {0}', github.event.inputs.commit_sha ) }}
98+ - Description: ${{ github.event.pull_request.body || 'Manually triggered documentation sync' }}
10399 - Files changed: ${{ steps.changed-files.outputs.changed_files }}
104- - Commit SHA: ${{ env.MERGE_COMMIT_SHA || env.COMMIT_SHA }}
100+ - Commit SHA: ${{ github.event.pull_request.merge_commit_sha || github.event.inputs.commit_sha }}
105101
106102 **Your tasks:**
107103 1. Review the changed files and PR description to understand what functionality was added, modified, or removed
@@ -126,12 +122,6 @@ jobs:
126122 - name : Create branch and commit changes
127123 if : steps.check-docs.outputs.needs_update == 'true'
128124 working-directory : docs-repo
129- env :
130- GITHUB_TOKEN : ${{ secrets.CREATE_PR_TOKEN }}
131- PR_TITLE : ${{ github.event.pull_request.title }}
132- PR_NUMBER : ${{ github.event.pull_request.number }}
133- COMMIT_SHA : ${{ github.event.inputs.commit_sha }}
134- CHANGED_FILES : ${{ steps.changed-files.outputs.changed_files }}
135125 run : |
136126 # Configure git
137127 git config user.name "github-actions[bot]"
@@ -146,19 +136,19 @@ jobs:
146136 # Add and commit changes
147137 git add .
148138 if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
149- git commit -m "docs: Update documentation for controller commit $COMMIT_SHA
139+ git commit -m "docs: Update documentation for controller commit ${{ github.event.inputs.commit_sha }}
150140
151- Updates documentation to reflect changes made in commit :
152- $COMMIT_SHA
153-
154- Manually triggered documentation sync"
141+ Updates documentation to reflect changes made in commit:
142+ ${{ github.event.inputs.commit_sha }}
143+
144+ Manually triggered documentation sync"
155145 else
156- git commit -m "docs : Update documentation for controller PR # $PR_NUMBER
157-
158- Updates documentation to reflect changes made in :
159- $PR_TITLE
146+ git commit -m "docs: Update documentation for controller PR #${{ github.event.pull_request.number }}
160147
161- Related controller PR : cartridge-gg/controller#$PR_NUMBER"
148+ Updates documentation to reflect changes made in:
149+ ${{ github.event.pull_request.title }}
150+
151+ Related controller PR: cartridge-gg/controller#${{ github.event.pull_request.number }}"
162152 fi
163153
164154 # Push branch
@@ -167,29 +157,31 @@ Related controller PR: cartridge-gg/controller#$PR_NUMBER"
167157 # Create PR
168158 if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
169159 gh pr create \
170- --title "docs : Update documentation for controller commit $COMMIT_SHA " \
171- --body "This PR updates the documentation to reflect changes made in cartridge-gg/controller commit $COMMIT_SHA
160+ --title "docs: Update documentation for controller commit ${{ github.event.inputs.commit_sha }} " \
161+ --body "This PR updates the documentation to reflect changes made in cartridge-gg/controller commit ${{ github.event.inputs.commit_sha }}
172162
173- **Commit Details:**
174- - Commit SHA : $COMMIT_SHA
175- - Files changed : $CHANGED_FILES
176- - Trigger : Manual documentation sync
163+ **Commit Details:**
164+ - Commit SHA: ${{ github.event.inputs.commit_sha }}
165+ - Files changed: ${{ steps.changed-files.outputs.changed_files }}
166+ - Trigger: Manual documentation sync
177167
178- Please review the documentation changes to ensure they accurately reflect the controller updates."
168+ Please review the documentation changes to ensure they accurately reflect the controller updates."
179169 else
180170 gh pr create \
181- --title "docs : Update documentation for controller PR # $PR_NUMBER " \
182- --body "This PR updates the documentation to reflect changes made in cartridge-gg/controller#$PR_NUMBER
171+ --title "docs: Update documentation for controller PR #${{ github.event.pull_request.number }} " \
172+ --body "This PR updates the documentation to reflect changes made in cartridge-gg/controller#${{ github.event.pull_request.number }}
183173
184- **Original PR Details:**
185- - Title : $PR_TITLE
186- - Files changed : $CHANGED_FILES
174+ **Original PR Details:**
175+ - Title: ${{ github.event.pull_request.title }}
176+ - Files changed: ${{ steps.changed-files.outputs.changed_files }}
187177
188- Please review the documentation changes to ensure they accurately reflect the controller updates."
178+ Please review the documentation changes to ensure they accurately reflect the controller updates."
189179 fi
190180 else
191181 echo "No documentation changes were made by Claude"
192182 fi
183+ env :
184+ GITHUB_TOKEN : ${{ secrets.CREATE_PR_TOKEN }}
193185
194186 - name : Cleanup
195187 if : always()
0 commit comments