6161 uses : anthropics/claude-code-action@beta
6262 with :
6363 anthropic_api_key : ${{ secrets.ANTHROPIC_API_KEY }}
64+ github_token : ${{ secrets.GITHUB_TOKEN }}
65+
6466 direct_prompt : |
6567 Generate a changelog entry for version ${{ steps.get_version.outputs.VERSION }} of the Cartridge Controller SDK.
6668
7072
7173 Analyze the git commit range: ${{ steps.commit_range.outputs.RANGE }}
7274
73- Create a changelog entry in this format and save it to a file called new-changelog-entry .md:
75+ Create a changelog entry in this format and update CHANGELOG .md:
7476
7577 ## [${{ steps.get_version.outputs.VERSION }}] - $(date +%Y-%m-%d)
7678
9395
9496 allowed_tools : " Read,Write,Bash"
9597
96- - name : Check if CHANGELOG.md exists
97- id : check_changelog
98- run : |
99- if [ -f "CHANGELOG.md" ]; then
100- echo "exists=true" >> $GITHUB_OUTPUT
101- else
102- echo "exists=false" >> $GITHUB_OUTPUT
103- fi
104-
105- - name : Create or update CHANGELOG.md
106- run : |
107- if [ "${{ steps.check_changelog.outputs.exists }}" == "true" ]; then
108- # Insert new entry after the header
109- if [ -f "new-changelog-entry.md" ]; then
110- # Create a temporary file
111- touch temp-changelog.md
112-
113- # Process the file line by line
114- header_found=false
115- first_version_found=false
116-
117- while IFS= read -r line; do
118- if [[ "$line" =~ ^#[[:space:]]Changelog ]]; then
119- # Found the header
120- echo "$line" >> temp-changelog.md
121- echo "" >> temp-changelog.md
122- header_found=true
123- elif [[ "$header_found" == "true" && "$first_version_found" == "false" && "$line" =~ ^##[[:space:]]\[ ]]; then
124- # Found the first version entry, insert new content before it
125- cat new-changelog-entry.md >> temp-changelog.md
126- echo "" >> temp-changelog.md
127- echo "$line" >> temp-changelog.md
128- first_version_found=true
129- else
130- # Copy all other lines as-is
131- echo "$line" >> temp-changelog.md
132- fi
133- done < CHANGELOG.md
134-
135- # If no version entries were found (empty changelog), append the new entry
136- if [[ "$first_version_found" == "false" && "$header_found" == "true" ]]; then
137- cat new-changelog-entry.md >> temp-changelog.md
138- fi
139-
140- # Replace the original file
141- mv temp-changelog.md CHANGELOG.md
142- fi
143- else
144- # Create new CHANGELOG.md
145- echo "# Changelog" > CHANGELOG.md
146- echo "" >> CHANGELOG.md
147- if [ -f "new-changelog-entry.md" ]; then
148- cat new-changelog-entry.md >> CHANGELOG.md
149- fi
150- fi
151-
15298 - name : Commit changelog changes
15399 run : |
154100 git config --local user.email "action@github.com"
@@ -160,7 +106,3 @@ jobs:
160106 git commit -m "Generate changelog for v${{ steps.get_version.outputs.VERSION }}"
161107 git push
162108 fi
163-
164- - name : Clean up temporary files
165- run : |
166- rm -f new-changelog-entry.md
0 commit comments