diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-26 15:57:59 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-26 15:57:59 +0300 |
| commit | 2debcec74c983c5a3821678daf6b4c4ef00fc51e (patch) | |
| tree | 02265acd4b2950fa4462cc9e0af6fc9d15f65149 /.github/workflows | |
| parent | e1a32e5865c3695bc73dd016db90b3fd671e92e8 (diff) | |
fix: restrict unapproved pull requests to bug fixes
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/pr-gate.yml | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/.github/workflows/pr-gate.yml b/.github/workflows/pr-gate.yml index dd1f5193..192168ad 100644 --- a/.github/workflows/pr-gate.yml +++ b/.github/workflows/pr-gate.yml @@ -2,7 +2,7 @@ name: PR Gate on: pull_request_target: - types: [opened, reopened, synchronize] + types: [opened, edited, reopened, synchronize] jobs: check-contributor: @@ -48,6 +48,13 @@ jobs: const prAuthor = pr.user.login; const changedLines = pr.additions + pr.deletions; + const eventPullRequestState = context.payload.pull_request.state; + if (action === 'edited' && + (eventPullRequestState !== 'open' || pr.state !== 'open')) { + core.info(`Ignoring edits to closed PR #${pullNumber}`); + return; + } + async function getPermission(username) { try { const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ @@ -176,7 +183,7 @@ jobs: const message = [ `Hi @${prAuthor}, thanks for your interest in contributing!`, '', - `Herdr automatically admits unapproved pull requests when the patch changes no more than ${MAX_UNAPPROVED_CHANGED_FILES} files and ${MAX_UNAPPROVED_CHANGED_LINES.toLocaleString('en-US')} total added or deleted lines.`, + `Herdr automatically admits focused bug fixes from unapproved contributors when the title uses \`fix: ...\` or \`fix(scope): ...\` and the patch changes no more than ${MAX_UNAPPROVED_CHANGED_FILES} files and ${MAX_UNAPPROVED_CHANGED_LINES.toLocaleString('en-US')} total added or deleted lines.`, '', reason, '', @@ -238,6 +245,14 @@ jobs: return; } + const hasFixTitle = /^fix(?:\([^)]+\))?:\s+\S/.test(pr.title); + if (!hasFixTitle) { + await closePullRequest( + 'Unapproved contributors may submit only focused bug fixes. If this pull request fixes a bug, rename it to use a conventional `fix: ...` or `fix(scope): ...` title, then tag a maintainer to review and reopen it.', + ); + return; + } + const exceedsBudget = pr.changed_files > MAX_UNAPPROVED_CHANGED_FILES || changedLines > MAX_UNAPPROVED_CHANGED_LINES; if (exceedsBudget) { |
