Skip to content

Instantly share code, notes, and snippets.

@guptabhaskar
Created January 20, 2026 11:20
Show Gist options
  • Select an option

  • Save guptabhaskar/bd9b4982deadf4b54d1752d3743b6df2 to your computer and use it in GitHub Desktop.

Select an option

Save guptabhaskar/bd9b4982deadf4b54d1752d3743b6df2 to your computer and use it in GitHub Desktop.
Weekly Changelog using Claude
name: Weekly Changelog
on:
schedule:
- cron: '0 9 * * 1' # Every Monday at 9:00 AM UTC
workflow_dispatch: # Allow manual trigger
jobs:
generate-changelog:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 100 # Get enough history for changelog
- name: Get last week's commits
id: commits
run: |
# Get commits from the past week, excluding merges
COMMITS=$(git log --oneline --since="1 week ago" --no-merges --format="%h %ad %s" --date=short)
echo "commits<<EOF" >> $GITHUB_OUTPUT
echo "$COMMITS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT
echo "week_start=$(date -d '1 week ago' +%Y-%m-%d)" >> $GITHUB_OUTPUT
- name: Check if there are commits
id: check_commits
run: |
if [ -z "${{ steps.commits.outputs.commits }}" ]; then
echo "has_commits=false" >> $GITHUB_OUTPUT
else
echo "has_commits=true" >> $GITHUB_OUTPUT
fi
- name: Generate changelog with Claude
if: steps.check_commits.outputs.has_commits == 'true'
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
settings: '{"model": "claude-sonnet-4-20250514", "permissions": {"allow": ["Bash", "Read", "Write", "Edit", "Glob", "Grep"]}}'
prompt: |
Generate a customer-facing changelog for the ImmigrantFirst platform based on these commits from the past week:
${{ steps.commits.outputs.commits }}
Follow these rules:
1. ONLY include user-facing changes (features, fixes, improvements users would notice)
2. EXCLUDE: dependency bumps, internal refactors, CI/CD changes, code cleanup, TypeScript fixes, linting changes
3. Group related commits into single entries
4. Write descriptions in plain language customers understand
5. Focus on the "why" and "benefit" not the technical "what"
IMPORTANT: Use the Read tool first to read the existing changelog file, then use the Edit tool to prepend the new entry.
First, read the existing changelog at apps/firm/public/changelog.json
Then, prepend a new entry to the "entries" array with this structure:
{
"id": "${{ steps.commits.outputs.date }}",
"date": "${{ steps.commits.outputs.date }}",
"weekStart": "${{ steps.commits.outputs.week_start }}",
"title": "[Brief descriptive title of the most significant change]",
"summary": "[One sentence summary of what shipped this week]",
"isMajor": false,
"changes": [
{
"type": "feature|fix|improvement|performance|security",
"title": "[Short title]",
"description": "[User-friendly description of the change and its benefit]"
}
]
}
Types guide:
- feature: New functionality
- fix: Bug fixes
- improvement: Enhancements to existing features
- performance: Speed or efficiency improvements
- security: Security-related changes
If there are no user-facing changes, set changes to an empty array and note "No user-facing changes this week" in the summary.
After updating the file, create a pull request with:
- Branch: changelog/${{ steps.commits.outputs.date }}
- Title: "Changelog: Week of ${{ steps.commits.outputs.date }}"
- Body: Summary of the changes included
claude_args: '--max-turns 25'
- name: Auto-merge changelog PR
if: steps.check_commits.outputs.has_commits == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Wait for PR to be created
sleep 10
# Find the PR created by this workflow
PR_NUMBER=$(gh pr list --head "changelog/${{ steps.commits.outputs.date }}" --json number --jq '.[0].number')
if [ -z "$PR_NUMBER" ]; then
echo "No PR found for changelog/${{ steps.commits.outputs.date }}"
exit 0
fi
echo "Found PR #$PR_NUMBER"
# Safety check: Verify PR only modifies changelog.json
CHANGED_FILES=$(gh pr diff "$PR_NUMBER" --name-only)
EXPECTED_FILE="apps/firm/public/changelog.json"
echo "Changed files in PR:"
echo "$CHANGED_FILES"
# Check if only changelog.json is modified
if [ "$CHANGED_FILES" = "$EXPECTED_FILE" ]; then
echo "Safety check passed: Only changelog.json modified"
echo "Enabling auto-merge..."
gh pr merge "$PR_NUMBER" --auto --squash
else
echo "Safety check FAILED: PR contains unexpected file changes"
echo "Expected only: $EXPECTED_FILE"
echo "Skipping auto-merge - manual review required"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment