Skip to content

Add matchBranch param to only return prs from the current branch - #356

Open
alkanna wants to merge 2 commits into
8BitJonny:masterfrom
alkanna:feat/match-branch
Open

alkanna wants to merge 2 commits into
8BitJonny:masterfrom
alkanna:feat/match-branch

Conversation

@alkanna

@alkanna alkanna commented Sep 22, 2026

Copy link
Copy Markdown

Fixes #8 .

Hello, I added amatchBranch input so that when enabled, the action only returns a PR whose head branch is the branch the workflow is running on. So if the same commit is pushed to two branches, each run only picks up its own PR. This is something we've been annoyed with too at the Treep, so I thought I'd contribute.

  • Branches are matched on the head label (owner:branch), so a fork with a branch of the same name won't match.
  • On any event that carries a PR payload, the branch comes from the PR head.
  • If sha is set explicitly, or the run isn't on a branch (tags, merge queue), the filter is skipped with a warning.

I also fixed a small bug in get-last-pr that could prevent filteroutdraft/closed from doing anything, I can take it out if you want.

Note that this does not cause any breaking change since it's opt-in so imo it can be released as 4.1.0.

@alkanna
alkanna requested a review from 8BitJonny as a code owner September 22, 2026 13:59
Copilot AI lite review requested due to automatic review settings September 22, 2026 13:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Merge-queue runs can be filtered incorrectly, and the bundled output must be regenerated; the documentation example also bypasses the new option.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds opt-in matchBranch filtering to select PRs associated with the workflow’s current branch, while fixing filtered PR selection.

Changes:

  • Adds branch-label matching and warnings for unsupported contexts.
  • Fixes draft/closed PR filtering.
  • Updates metadata, documentation, tests, and bundled output.
File Summary
src/​main.ts Passes branch-matching options to PR selection.
src/​io/​get-inputs.ts Derives branch labels; moderate: merge-queue events should skip branch filtering.
src/​get-last-pr.ts Applies branch and status filters.
README.md Documents matchBranch; nit: the example’s explicit sha bypasses the branch filter.
dist/​index.js Updates the packaged action; moderate: regenerate after fixing merge-queue handling; nit: remove comments not present in source.
action.yml Declares the new input.
__tests__/​main.test.ts Adds branch-matching tests.
__tests__/​create-dummy-pr.ts Supports PR head labels in fixtures.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/io/get-inputs.ts Resolved
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.

Feature Proposal: Match Branch when checking for PR

2 participants