fix: Changelog check detects blog posts across all PR commits#1646
fix: Changelog check detects blog posts across all PR commits#1646
Conversation
The changelog check was failing on PRs with multiple commits because it only looked at the diff between the latest commit and the base branch. If a blog post was added in an earlier commit, subsequent commits would not see it as a "new" file. Changes: - Use 'gh pr diff' instead of 'git diff' to get all files in the PR - This captures files added in any commit of the PR, not just HEAD - Exclude tags.yml from blog post detection (meta file, not a post) - Add GH_TOKEN env for gh CLI authentication This fixes false positives where: 1. Blog post added in commit A 2. Additional commits B, C pushed to PR 3. Workflow runs on commit C, doesn't see blog post as "new" Now the workflow correctly identifies blog posts regardless of which commit they were added in. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
📝 WalkthroughWalkthroughReplaces base-branch git-diff with a PR-scoped Changes
Sequence Diagram(s)sequenceDiagram
participant GH as GitHub Actions
participant GHCli as gh CLI
participant WF as Workflow Logic
rect rgb(255, 245, 230)
Note over GH,WF: Branch-target gating
GH->>GH: read BASE_REF (target branch)
alt BASE_REF != "main"
GH->>WF: short-circuit -> no changelog required
else BASE_REF == "main"
GH->>WF: continue
end
end
rect rgb(230, 245, 255)
Note over GH,GHCli: PR-scoped blog discovery
GH->>GHCli: gh pr diff $PR_NUMBER (uses GH_TOKEN)
GHCli-->>GH: list of files added/changed in PR
GH->>GH: filter website/blog/*.md/*.mdx
GH->>GH: exclude tags.yml
alt files found
GH->>WF: set has_changelog = true
else no files
GH->>WF: set has_changelog = false
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Important Cloud Posse Engineering Team Review RequiredThis pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes. To expedite this process, reach out to us on Slack in the |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/changelog-check.yml (1)
40-41: Fail fast whengh pr diffblows up
|| trueswallows any failure fromgh pr diff, so an auth/network blip looks identical to “no blog post found”, which sends folks on a goose chase. Please surface those command failures and only relax the exit code on the finalgrepso we keep the helpful changelog messaging without hiding real errors. For example:- NEW_BLOG_FILES=$(gh pr diff $PR_NUMBER --name-only | grep -E '^website/blog/.*\.(md|mdx)$' | grep -v 'tags.yml' || true) + RAW_DIFF=$(gh pr diff "$PR_NUMBER" --name-only) || { echo "Failed to fetch PR diff" >&2; exit 1; } + NEW_BLOG_FILES=$(echo "$RAW_DIFF" | grep -E '^website/blog/.*\.(md|mdx)$' | grep -v 'tags.yml' || true)
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/changelog-check.yml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Lint (golangci)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (go)
- GitHub Check: Lint (golangci)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Build (macos-latest, macos)
- GitHub Check: Lint (golangci)
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (go)
- GitHub Check: Lint (golangci)
- GitHub Check: Summary
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1646 +/- ##
==========================================
+ Coverage 64.97% 65.00% +0.03%
==========================================
Files 338 338
Lines 37535 37535
==========================================
+ Hits 24388 24400 +12
+ Misses 11201 11187 -14
- Partials 1946 1948 +2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Changelog entries (blog posts) should only be required for PRs that target the main branch. PRs targeting feature branches or other branches don't need changelog entries. Changes: - Check PR base ref before requiring changelog - Skip changelog check if base ref is not 'main' - Update step name to clarify it checks both label and target branch - Add clear messaging when skipping due to non-main target This allows: - Feature branch PRs to skip changelog requirements - Backport PRs to release branches to skip changelog requirements - Only main-bound PRs with minor/major labels need changelog entries 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
These changes were released in v1.195.0-test.0. |
what
git difftogh pr diffto capture all files modified in the entire PRtags.ymlfrom blog post detection (it's a meta file, not a blog post)why
references
Summary by CodeRabbit