Skip to content

feat: add Update Changelogs workflow with auto-changelog v6 --checkDeps#8443

Merged
Mrtenz merged 34 commits intomainfrom
feat/auto-changelog-check-deps
Apr 22, 2026
Merged

feat: add Update Changelogs workflow with auto-changelog v6 --checkDeps#8443
Mrtenz merged 34 commits intomainfrom
feat/auto-changelog-check-deps

Conversation

@cryptodev-2s
Copy link
Copy Markdown
Contributor

@cryptodev-2s cryptodev-2s commented Apr 13, 2026

Explanation

Adds an Update Changelogs workflow that uses @metamask/auto-changelog v6's --checkDeps --fix feature to automatically validate and fix missing dependency bump changelog entries.

Triggers:

  • Automatic: When a release PR (release/* branch) is opened targeting main
  • On-demand: Comment @metamaskbot update-changelogs on any non-fork PR

What it does:

  1. Detects and skips fork PRs (security)
  2. Checks out the PR head branch
  3. Runs changelog:validate --checkDeps --fix --currentPr <PR#> across all packages
  4. Commits and pushes any CHANGELOG.md fixes back to the PR branch
  5. Comments on the PR with the result

Security:

  • Fork PRs are blocked via isCrossRepository check
  • All dynamic values use environment variables (no ${{ }} in run: blocks)
  • SHA-based checkout with branch name switch for release branch detection

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Adds CI automation that runs with contents: write and can push commits to PR branches and post/minimize comments, so misconfiguration could affect contributor branches or spam PRs; code changes are limited to GitHub workflow logic.

Overview
Adds a new Update Changelogs workflow that, for non-fork PRs, detects release PRs (or a @metamaskbot update-changelogs comment), runs yarn changelog:validate --checkDeps --fix from the PR’s merge-base, and auto-commits/pushes any **/CHANGELOG.md fixes back to the PR branch with a status comment (minimizing prior bot comments).

Makes release detection configurable by introducing a commit-starts-with input to the check-release composite action and wiring both check-release and the is-release job in main.yml to use ${{ vars.RELEASE_COMMIT_PREFIX }} instead of a hardcoded prefix list.

Reviewed by Cursor Bugbot for commit c6e02fe. Bugbot is set up for automated code reviews on this repo. Configure here.

@cryptodev-2s cryptodev-2s requested a review from a team as a code owner April 13, 2026 21:20
Comment thread .github/workflows/fix-changelogs.yml Fixed
Comment thread .github/workflows/fix-changelogs.yml Outdated
Comment thread .github/workflows/fix-changelogs.yml Outdated
Comment thread .github/workflows/fix-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
@cryptodev-2s cryptodev-2s changed the title feat: adopt auto-changelog v6 --checkDeps for dependency bump validation feat: add Update Changelogs workflow with auto-changelog v6 --checkDeps Apr 14, 2026
- Add --checkDeps to validate-changelog.sh to catch missing dep entries
- Add --checkDeps --fix to update-changelog.sh to auto-generate dep entries
- Add fix-changelogs workflow to auto-fix changelogs on release branches
- --checkDeps/--fix are validate-only flags, revert from update-changelog.sh
- Skip --checkDeps on main branch to avoid "HEAD is same as base" error
- Workflow uses validate --checkDeps --fix with PR number for auto-fixing
Keep dependency bump validation opt-in via @metamaskbot check-deps only.
- Add missing --checkDeps flag to validate step
- Fix shell quoting bug in fork detection
- Narrow git add to **/CHANGELOG.md only
- Report validation failures in PR comment instead of swallowing them
- Use chore: prefix for automated commit message
- Add concurrency group to prevent racing on duplicate triggers
- Add if: always() to comment step so users always get feedback
- Add comment explaining branch checkout purpose
- Remove -A flag from git add (only staging tracked CHANGELOG.md files)
- Improve step name and commit message for clarity
- Add pull_request opened trigger for release/* branches targeting main
- Use github.event.issue.number || github.event.pull_request.number for both triggers
- Conditionally show reaction only for comment triggers
- Rename file from fix-changelogs.yml to update-changelogs.yml
- Update workflow name, job names, and concurrency group
- Rename bot command to @metamaskbot update-changelogs
- Add git fetch before branch checkout (shallow clone has no branch refs)
- Handle partial fix case: report remaining errors when fixes are pushed
- Handle skipped steps: detect when earlier steps fail and report accurately
- Rename job ID from fix-changelogs to update-changelogs for consistency
@cryptodev-2s cryptodev-2s force-pushed the feat/auto-changelog-check-deps branch from 772928a to f4aabbb Compare April 14, 2026 13:58
Comment thread .github/workflows/update-changelogs.yml Outdated
Shallow clone with fetch-depth: 1 doesn't include origin/main,
causing --checkDeps to fail with "could not resolve base branch".
- Use fetch-depth: 0 so git merge-base can find common ancestor with main
- Hide previous bot comments on rerun to reduce noise
- Add emoji to comment messages for clarity
- Add --paginate to handle PRs with many comments
- Use precise emoji-anchored regex to match only this workflow's comments
- Add continue-on-error so comment hiding doesn't block core workflow
Comment thread .github/workflows/update-changelogs.yml Outdated
Use patroll-managed PAT so commits pushed by this workflow trigger
subsequent CI workflows (GITHUB_TOKEN commits don't trigger workflows).

Depends on: MetaMask/patroll#75
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Fixed
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Mrtenz and others added 3 commits April 20, 2026 12:14
…OCTOU'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Comment thread .github/workflows/update-changelogs.yml
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Outdated
Comment thread .github/workflows/update-changelogs.yml Dismissed
Comment thread .github/workflows/update-changelogs.yml Dismissed
Comment on lines +4 to +7
inputs:
commit-starts-with:
description: "Validate that the release commit starts with a string in this comma-separated list. Use '[version]' to refer to the current release version."
required: true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actions don't have access to vars directly.

set -euo pipefail

MERGE_BASE=$(git merge-base HEAD "refs/remotes/origin/$BASE_REF")
echo "merge-base=$MERGE_BASE" >> "$GITHUB_OUTPUT"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge base is needed to determine the before commit for action-is-release.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. auto-changelog also takes a "before" commit via a --from option. If this is not given it will calculate its own merge base: https://github.com/MetaMask/auto-changelog/blob/902c1f9b54dd3c61f938475400da46ac1cb04e4c/src/get-dependency-changes.ts#L198. So now we have two places that perform this step (in two different ways). Maybe we should capture the result of this step and pass it to auto-changelog via --from so that we're using the same approach?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

run: |
git fetch --no-tags origin "$PR_HEAD_SHA"
git fetch --no-tags origin "$PR_BASE_REF"
git checkout --detach "$PR_HEAD_SHA"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommended by CodeQL.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ccae16b. Configure here.

Comment thread .github/workflows/update-changelogs.yml
Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow is surprisingly complicated, but it does all make sense. I just had two more comments.

Comment thread .github/workflows/update-changelogs.yml
set -euo pipefail

MERGE_BASE=$(git merge-base HEAD "refs/remotes/origin/$BASE_REF")
echo "merge-base=$MERGE_BASE" >> "$GITHUB_OUTPUT"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. auto-changelog also takes a "before" commit via a --from option. If this is not given it will calculate its own merge base: https://github.com/MetaMask/auto-changelog/blob/902c1f9b54dd3c61f938475400da46ac1cb04e4c/src/get-dependency-changes.ts#L198. So now we have two places that perform this step (in two different ways). Maybe we should capture the result of this step and pass it to auto-changelog via --from so that we're using the same approach?

@Mrtenz
Copy link
Copy Markdown
Member

Mrtenz commented Apr 20, 2026

This workflow is surprisingly complicated, but it does all make sense. I just had two more comments.

@mcmire It definitely gets a lot more complicated because we need to support running it when opening a pull request and when leaving a comment. I rewrote some bash scripts to use github-script since (at least to me) it's more readable. Other than that, I'm not sure if it can be simplified further.

Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Mrtenz Mrtenz added this pull request to the merge queue Apr 22, 2026
Merged via the queue into main with commit 5801bc0 Apr 22, 2026
350 checks passed
@Mrtenz Mrtenz deleted the feat/auto-changelog-check-deps branch April 22, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants