Skip to content

ci: improve merge-approved-pr.yml#201

Merged
HowardBraham merged 5 commits intomainfrom
merge-method
Feb 24, 2026
Merged

ci: improve merge-approved-pr.yml#201
HowardBraham merged 5 commits intomainfrom
merge-method

Conversation

@HowardBraham
Copy link
Contributor

@HowardBraham HowardBraham commented Jan 8, 2026

  • Adds reusable-workflow inputs:

    • merge-method (merge default, the workflow now supports squash)
    • verify-version-bump (boolean input, default false)
  • Hardens all inputs used in bash or script to be env vars

  • If verify-version-bump is true, then verify that

    • the only change is in package.json
    • the only line changed is "version"
    • the version change is a valid semver bump

Note

Medium Risk
Changes CI automation that can merge PRs, including new gating logic and squash support; misconfiguration or token permission issues could cause unintended merges or blocked releases.

Overview
Refactors the merge-approved-pr reusable workflow into a new composite action (.github/actions/merge-approved-pr) and simplifies the workflow to delegate to it (marked deprecated).

The action adds configurable merge-method (merge/squash), hardens input handling by passing values through env vars, and optionally enforces a version-bump-only policy by validating that the PR changes only package.json and only the version line with a valid semver +1 bump before allowing the merge.

Written by Cursor Bugbot for commit ad58d2d. This will update automatically on new commits. Configure here.

@HowardBraham
Copy link
Contributor Author

Going with a different solution to this issue

@HowardBraham HowardBraham reopened this Feb 22, 2026
@HowardBraham HowardBraham changed the title ci: give "Merge Approved PR" a merge-method input ci: improve merge-approved-pr.yml Feb 22, 2026
@HowardBraham HowardBraham requested a review from Copilot February 23, 2026 01:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the reusable merge-approved-pr.yml workflow with additional configuration options and stricter validation capabilities. It introduces a merge-method input allowing callers to choose between merge commits and squash merges, and adds an optional verify-version-bump feature that validates PRs contain only a valid semantic version bump in package.json. The changes also refactor the workflow to use environment variables consistently across all steps, improving maintainability and reducing direct input references.

Changes:

  • Added configurable merge method support (merge or squash) with input validation
  • Implemented version bump verification to ensure PRs only change package.json version field with valid semver bumps
  • Converted step outputs to workflow-level environment variables for consistent access patterns

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

Choose a reason for hiding this comment

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

Can this be an action, rather than a reusable workflow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hah, I literally got halfway into writing it that way and then decided against it. Should it be?

Copy link
Member

Choose a reason for hiding this comment

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

I've updated most workflows to actions a little while ago. Mainly to be able to access github.action_ref and reduce the number of anti patterns in this repo, though I don't think that's relevant for this specific workflow.

Doesn't look like we need any of the workflow features (like matrices, parallelisation) here, so I would prefer using an action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's an action now. Should we remove the wrapper stub at .github/workflows/merge-approved-pr.yml?

If we remove it, I think we would have to bump the whole github-tools to v2 because it causes an incompatibility.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe just deprecate it for now, so we don't have to release a new major?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah how do we signify a deprecated wrapper stub?

Copy link
Member

Choose a reason for hiding this comment

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

Apparently the deprecation notice is only for actions, not for reusable workflows. 😅 Just a comment on the top of the workflow is fine I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Anything else left to do here?

Copy link
Member

Choose a reason for hiding this comment

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

Nope, looks good to me.

Copy link
Member

@Mrtenz Mrtenz left a comment

Choose a reason for hiding this comment

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

Just one more nit.

@HowardBraham HowardBraham requested a review from Mrtenz February 24, 2026 17:56
Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
Copy link

@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.

'Validation failed: PR must only change package.json when verify-version-bump is enabled.',
);
return;
}
Copy link

Choose a reason for hiding this comment

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

Version bump rejects package.json in subdirectories

Low Severity

The version-bump check uses an exact match files[0].filename !== 'package.json', so only changes to the repository-root package.json pass. When verify-version-bump is true and the only change is a version bump in a subpackage (e.g., packages/core/package.json), validation incorrectly fails with "PR must only change package.json". GitHub's listFiles API returns the full path in filename, so subdirectory package.json files are rejected.

Fix in Cursor Fix in Web

@HowardBraham HowardBraham merged commit 76160be into main Feb 24, 2026
21 checks passed
@HowardBraham HowardBraham deleted the merge-method branch February 24, 2026 18:01
tommasini added a commit that referenced this pull request Feb 24, 2026
tommasini added a commit that referenced this pull request Feb 24, 2026
* 1.7.0

* Update CHANGELOG.md

* Update CHANGELOG.md

* add #201 to changelog

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: sethkfman <10342624+sethkfman@users.noreply.github.com>
Co-authored-by: tommasini <tommasini15@gmail.com>
Co-authored-by: tommasini <46944231+tommasini@users.noreply.github.com>
@Gudahtt Gudahtt mentioned this pull request Feb 24, 2026
github-merge-queue bot pushed a commit to MetaMask/metamask-extension that referenced this pull request Feb 25, 2026
## **Description**

- Combines `merge-stable-sync-pr.yml` and `merge-version-bump-pr.yml`
into a single workflow
- `merge-version-bump-pr` now uses the new inputs `merge-method:
'squash'` and `verify-version-bump: true`
  - Changed here: MetaMask/github-tools#201

Tested on the consensys-test/metamask-extension-test-workflow2 repo:
-
consensys-test#231
-
consensys-test#232

## **Changelog**

CHANGELOG entry: null

<!--## **Related issues**
## **Manual testing steps**
## **Screenshots/Recordings**
## **Pre-merge author checklist**
## **Pre-merge reviewer checklist**
[skip-e2e]-->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes CI automation that can auto-merge PRs; incorrect branch
matching or action inputs could merge the wrong PRs or change merge
semantics.
> 
> **Overview**
> Consolidates the two comment-triggered auto-merge workflows into a
single `merge-my-pr.yml` that looks up the PR head branch via the GitHub
API and then conditionally merges based on whether it matches
`version-bump/X.Y.Z` or `stable-main-X.Y.Z`.
> 
> Updates merge behavior: version-bump PRs now *squash merge* and enable
`verify-version-bump: true`, while stable-main PRs use a regular *merge*
method. The old `merge-stable-sync-pr.yml` and
`merge-version-bump-pr.yml` workflows are removed.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
cc287b7. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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