Skip to content

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

Open
cryptodev-2s wants to merge 23 commits intomainfrom
feat/auto-changelog-check-deps
Open

feat: add Update Changelogs workflow with auto-changelog v6 --checkDeps#8443
cryptodev-2s wants to merge 23 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
  • 30-minute job timeout

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
Introduces an automated workflow that runs on PR events/comments and uses a write-scoped token to commit/push changes; misconfiguration could lead to unintended updates or token exposure, though fork PRs are explicitly skipped.

Overview
Adds a new GitHub Actions workflow update-changelogs.yml that can be triggered on release PR open (branch release/* targeting main) or via an @metamaskbot update-changelogs PR comment to run changelog:validate --checkDeps --fix across workspaces.

If the PR is not from a fork, the workflow checks out the PR, minimizes prior bot status comments, commits and pushes any **/CHANGELOG.md fixes back to the branch using UPDATE_CHANGELOG_TOKEN, then posts a success/warning/failure status comment on the PR.

Reviewed by Cursor Bugbot for commit bbac608. 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
Comment thread .github/workflows/update-changelogs.yml
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
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
MetaMask/action-checkout-and-setup doesn't accept a token input,
so the PAT was silently ignored. Use actions/checkout with the PAT
first, then gh pr checkout, then action-checkout-and-setup for
node/yarn setup (it skips checkout if .git already exists).
Comment thread .github/workflows/update-changelogs.yml Dismissed
Comment thread .github/workflows/update-changelogs.yml Outdated
- Remove unused "Get PR head ref" step (gh pr checkout handles it)
- Simplify comment-hiding regex to ^(✅|⚠️|❌) to match all 6 variants
- Set GITHUB_TOKEN and PR_NUMBER at job level to reduce repetition
- Remove per-step env overrides that are now inherited
Comment thread .github/workflows/update-changelogs.yml
The PAT lacks issues:write permission needed for reactions and comments.
Override GITHUB_TOKEN with github.token on steps that interact with the
GitHub API (reactions, hiding comments, posting results).
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.

There are 2 total unresolved issues (including 1 from previous review).

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 bbac608. Configure here.

run: gh api "repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}/reactions" -f content='+1'
env:
GH_TOKEN: ${{ github.token }}
COMMENT_ID: ${{ github.event.comment.id }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing continue-on-error on reaction step blocks workflow

Medium Severity

The "React to comment" step lacks continue-on-error: true, so a transient API failure or rate-limit when adding the 👍 reaction will abort the entire job. All subsequent steps (checkout, validate, fix, commit, push) are skipped, and the comment step reports a misleading "Workflow failed before changelog validation." The "Hide previous bot comments" step at line 72 correctly uses continue-on-error: true for a similarly non-critical API call, but this step does not.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bbac608. Configure here.

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.

I guess this is true, yes. We should probably add this.

is-fork-pull-request:
name: Determine whether this PR is from a fork
if: >
(github.event_name == 'pull_request' && startsWith(github.head_ref, '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.

Release branches aren't required to start with release/. We used to check for release branches this way, but now we have a more sophisticated check. You should be able to use the is-release action to determine this. See how we do this in main.yml:

is-release:
name: Determine whether this is a release merge commit
needs: lint-build-test
if: github.event_name == 'push'
runs-on: ubuntu-latest
outputs:
IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }}
steps:
- id: is-release
uses: MetaMask/action-is-release@v2
with:
commit-starts-with: 'Release [version],Release v[version],Release/[version],Release/v[version],Release `[version]`'

(Maybe we want to extract this step to a separate internal action so we don't have to repeat the list of commit patterns?)

needs: is-fork-pull-request
if: ${{ needs.is-fork-pull-request.outputs.IS_FORK == 'false' }}
runs-on: ubuntu-latest
timeout-minutes: 30
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.

I thought jobs automatically timed out? I see that you borrowed this from the extension repo, but we haven't been specifying timeouts in this repo so I'm curious if it's really necessary.

Suggested change
timeout-minutes: 30

run: gh api "repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}/reactions" -f content='+1'
env:
GH_TOKEN: ${{ github.token }}
COMMENT_ID: ${{ github.event.comment.id }}
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.

I guess this is true, yes. We should probably add this.

Comment on lines +97 to +98
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
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.

Is this necessary? I thought using the token to check out the repo automatically sets the user name and email.

cache-node-modules: true
node-version: 22.x

- name: Hide previous bot comments
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.

Maybe we should only do this once we've confirmed that we need to post a new comment?

env:
GH_TOKEN: ${{ github.token }}
CHANGED: ${{ steps.commit.outputs.changed }}
COMMIT_OUTCOME: ${{ steps.commit.outcome }}
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.

Nit: Should we use a more descriptive name for this step?

Suggested change
COMMIT_OUTCOME: ${{ steps.commit.outcome }}
PUSH_CHANGES_OUTCOME: ${{ steps.push-changes.outcome }}

continue-on-error: true

- name: Commit and push if changed
id: commit
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.

Nit: Should we use a more descriptive step ID?

Suggested change
id: commit
id: push-changes

id: commit
run: |
if git diff --quiet; then
echo "changed=false" >> "$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.

The name of this output seems to indicate that tracks whether there were changes, but this is inaccurate. This tracks not only whether there were changes, but also whether they were pushed. Maybe this should be:

Suggested change
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "changes_pushed=false" >> "$GITHUB_OUTPUT"

git add -- '**/CHANGELOG.md'
git commit -m "chore: auto-fix dependency bump changelog entries"
git push
echo "changed=true" >> "$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.

Suggested change
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "changes_pushed=true" >> "$GITHUB_OUTPUT"

if: always()
run: |
if [ "$CHANGED" = "true" ] && [ "$VALIDATE_OUTCOME" = "failure" ]; then
gh pr comment "$PR_NUMBER" --body "⚠️ Changelogs updated and pushed, but some validation errors remain. Check the [workflow run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) for details."
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.

I wonder how this could happen 🤔 This would seem to indicate that changes were pushed when they were not supposed to be.

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.

3 participants