Skip to content

Commit aa38bee

Browse files
committed
ci(workflows): simplify docs review workflow and fix changelog extraction
Change-Id: I5b263e9cdd9af5f126ef358c67a743eaaecff8a2 Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 62c9f70 commit aa38bee

File tree

4 files changed

+23
-142
lines changed

4 files changed

+23
-142
lines changed

.github/workflows/claude-review.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
- name: Run Code Review with Claude
2222
id: code-review
23-
uses: anthropics/claude-code-action@8b9d5bb25a638c9aa5103496c0139d99b4936d42 # beta
23+
uses: anthropics/claude-code-action@8e84799f37d42f24e0ebae41205346879bdcab5a # v0.0.7
2424
with:
2525
# Define the review focus areas
2626
prompt: "Review the PR changes. Focus on code quality, potential bugs, and performance issues. Suggest improvements where appropriate."

.github/workflows/claude.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ jobs:
3333

3434
- name: Run Claude Code
3535
id: claude
36-
uses: anthropics/claude-code-action@8b9d5bb25a638c9aa5103496c0139d99b4936d42 # beta
36+
uses: anthropics/claude-code-action@8e84799f37d42f24e0ebae41205346879bdcab5a # v0.0.7
3737
with:
3838
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

.github/workflows/docs-review.yml

Lines changed: 19 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424

2525
- name: Run Claude Code to review documentation
2626
id: claude-review
27-
uses: anthropics/claude-code-action@8b9d5bb25a638c9aa5103496c0139d99b4936d42 # beta
27+
uses: anthropics/claude-code-action@8e84799f37d42f24e0ebae41205346879bdcab5a # v0.0.7
2828
with:
2929
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
3030
prompt: |
31-
As a Documentation Validator, your task is to review the current code in this repository and ensure that the markdown documentation files (README.md, ARCHITECTURE.md, and DEVELOPMENT.md) are up-to-date and accurate.
31+
As a Documentation Validator, review the current code in this repository and ensure that the markdown documentation files (README.md, ARCHITECTURE.md, and DEVELOPMENT.md) are up-to-date and accurate.
3232
3333
Focus on these specific areas:
3434
1. Configuration options - Ensure all config options in lua/claudecode/config.lua are accurately reflected in README.md
@@ -37,155 +37,35 @@ jobs:
3737
4. Development status - Review the implementation status in DEVELOPMENT.md against the actual codebase
3838
5. Terminal feature - Check that the terminal integration is documented correctly across all files
3939
40-
For any inconsistencies found:
41-
1. Note the specific issue (what's incorrect, missing, or outdated)
42-
2. Provide the correct information based on the current codebase
43-
3. Create a corrected version of the relevant section
40+
If you find any inconsistencies:
41+
1. Update the documentation files directly with the correct information
42+
2. Make the changes minimal and focused
43+
3. Ensure all changes are accurate based on the current codebase
4444
45-
Output your findings in this format:
46-
```json
47-
{
48-
"review_date": "YYYY-MM-DD",
49-
"files_checked": ["README.md", "ARCHITECTURE.md", "DEVELOPMENT.md"],
50-
"issues_found": [
51-
{
52-
"file": "path/to/file.md",
53-
"section": "Section title",
54-
"issue": "Description of inconsistency",
55-
"corrected_content": "The corrected markdown content"
56-
}
57-
]
58-
}
59-
```
45+
After making any necessary updates, create a git commit with the message "docs: update documentation to match current codebase" if changes were made.
6046
61-
If no issues are found, return an empty "issues_found" array.
62-
63-
- name: Process documentation updates
64-
id: process-updates
65-
shell: bash
66-
# zizmor-disable-next-line template-injection
67-
env:
68-
CLAUDE_OUTPUT: ${{ steps.claude-review.outputs.result }}
69-
run: |
70-
# Extract issues from Claude's output
71-
72-
# Check if the output contains the expected JSON format
73-
if ! echo "$CLAUDE_OUTPUT" | grep -q "\"issues_found\""; then
74-
echo "No valid JSON output found from Claude review"
75-
exit 0
76-
fi
77-
78-
# Extract the JSON part (between ```json and ```)
79-
echo "$CLAUDE_OUTPUT" | sed -n "/\`\`\`json/,/\`\`\`/p" | sed "1d;\$d" > json_output.txt
80-
echo "JSON output extracted"
81-
82-
# Parse the JSON and check if there are issues
83-
ISSUES_FOUND=$(jq ".issues_found | length" json_output.txt)
84-
echo "Issues found: $ISSUES_FOUND"
85-
86-
# Clean up json_output.txt if no issues are found or after processing
87-
if [ "$ISSUES_FOUND" -eq 0 ]; then
88-
echo "No documentation issues found"
89-
rm -f json_output.txt # Clean up if exiting early
90-
exit 0
91-
fi
92-
93-
if [ "$ISSUES_FOUND" -eq 0 ]; then
94-
echo "No documentation issues found"
95-
exit 0
96-
fi
97-
98-
echo "Found $ISSUES_FOUND documentation issues to fix"
99-
echo "issues_found=$ISSUES_FOUND" >> "$GITHUB_OUTPUT"
100-
101-
# Create a new branch for the fixes
102-
BRANCH_NAME="docs/update-$(date +%Y%m%d%H%M%S)"
103-
git checkout -b "$BRANCH_NAME"
104-
105-
# Apply each correction - use a safer approach
106-
for i in $(seq 0 $((ISSUES_FOUND - 1))); do
107-
# Extract each field safely into separate files
108-
jq -r ".issues_found[$i].file" json_output.txt > issue_file.txt
109-
jq -r ".issues_found[$i].section" json_output.txt > issue_section.txt
110-
jq -r ".issues_found[$i].issue" json_output.txt > issue_desc.txt
111-
jq -r ".issues_found[$i].corrected_content" json_output.txt > issue_content.txt
112-
113-
# Read from files
114-
FILE=$(cat issue_file.txt)
115-
SECTION=$(cat issue_section.txt)
116-
ISSUE=$(cat issue_desc.txt)
117-
CONTENT=$(cat issue_content.txt)
118-
119-
echo "Updating $FILE - Section: $SECTION"
120-
121-
# Escape content for sed using files for safety
122-
sed -E "s/[\/&]/\\&/g" issue_content.txt > escaped_content.txt
123-
ESCAPED_CONTENT=$(cat escaped_content.txt)
124-
125-
# Look for the section and apply the change
126-
# This is a basic approach; more sophisticated section matching might be needed
127-
if grep -q "$SECTION" "$FILE"; then
128-
# Try to find the section and replace content from the section title until the next section
129-
sed -i "/# $SECTION/,/# /c\\# $SECTION\n\n$ESCAPED_CONTENT\n\n# " "$FILE"
130-
else
131-
echo "Section not found: $SECTION in $FILE. Adding to the end of the file."
132-
echo -e "\n# $SECTION\n\n$CONTENT" >> "$FILE"
133-
fi
134-
done
135-
136-
# Clean up temporary files used in the loop
137-
rm -f issue_file.txt issue_section.txt issue_desc.txt issue_content.txt escaped_content.txt
138-
# Clean up json_output.txt after it's fully processed
139-
rm -f json_output.txt
140-
141-
# Set up git identity for Claude
142-
git config --local user.email "[email protected]"
143-
git config --local user.name "Claude"
144-
145-
# Commit the changes
146-
git add README.md ARCHITECTURE.md DEVELOPMENT.md
147-
git commit -m "docs: update documentation based on code analysis"
148-
git push origin "$BRANCH_NAME"
149-
150-
echo "branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT"
151-
152-
# Create summary of changes to display in PR
153-
CHANGES_SUMMARY=""
154-
for i in $(seq 0 $((ISSUES_FOUND - 1))); do
155-
FILE=$(echo "$JSON_OUTPUT" | jq -r ".issues_found[$i].file")
156-
SECTION=$(echo "$JSON_OUTPUT" | jq -r ".issues_found[$i].section")
157-
ISSUE=$(echo "$JSON_OUTPUT" | jq -r ".issues_found[$i].issue")
158-
159-
CHANGES_SUMMARY="${CHANGES_SUMMARY}- **${FILE}** (${SECTION}): ${ISSUE}\n"
160-
done
161-
162-
{
163-
echo "changes_summary<<EOF"
164-
echo -e "$CHANGES_SUMMARY"
165-
echo "EOF"
166-
} >> "$GITHUB_OUTPUT"
167-
168-
- name: Create Pull Request
169-
if: steps.process-updates.outputs.issues_found > 0
170-
uses: anthropics/claude-pr-action@8b9d5bb25a638c9aa5103496c0139d99b4936d42 # v1
47+
- name: Create Pull Request if changes were made
48+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
17149
with:
172-
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
173-
github_token: ${{ secrets.GITHUB_TOKEN }}
174-
branch: ${{ steps.process-updates.outputs.branch_name }}
175-
base: main
50+
token: ${{ secrets.GITHUB_TOKEN }}
51+
commit-message: "docs: update documentation to match current codebase"
17652
title: "docs: Update documentation to match current codebase"
17753
body: |
17854
This PR was automatically generated by Claude Code to update documentation files based on code analysis.
17955
18056
## What's Changed
18157
182-
Documentation has been updated to match the current codebase. The following issues were addressed:
183-
184-
${{ steps.process-updates.outputs.changes_summary }}
58+
Documentation has been updated to match the current codebase state:
59+
- Configuration options synchronized with actual code
60+
- Commands and usage examples verified
61+
- Architecture details updated to reflect current structure
62+
- Development status aligned with implementation
18563
186-
The following files were updated:
64+
## Files Updated
18765
- README.md
18866
- ARCHITECTURE.md
18967
- DEVELOPMENT.md
19068
19169
Please review these changes to ensure they accurately reflect the current state of the project.
70+
branch: docs/auto-update
71+
delete-branch: true

.github/workflows/update-changelog.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jobs:
2323
shell: bash
2424
# zizmor-disable-next-line template-injection
2525
run: |
26-
COMMIT_MSG=$(git log -1 --pretty=%B)
26+
# Get only the first line of commit message (subject line)
27+
COMMIT_MSG=$(git log -1 --pretty=%s)
2728
{
2829
echo "commit_msg=${COMMIT_MSG}"
2930
echo "commit_type=$(echo "${COMMIT_MSG}" | grep -o '^feat\|^fix\|^docs\|^style\|^refactor\|^perf\|^test\|^build\|^ci\|^chore' || echo 'other')"

0 commit comments

Comments
 (0)