From 4373498068da356fe64d784799faa86c129503a1 Mon Sep 17 00:00:00 2001 From: Emmanuel N Kyeyune Date: Tue, 8 Sep 2026 14:54:28 -0400 Subject: [PATCH] fix(ci): stop opening duplicate schema update PRs The existing-PR check passed a branch prefix to the head filter of pulls.list, which only matches an exact branch name, so it always reported no open PR. Paginate all open PRs and filter by prefix instead. --- .github/workflows/schema-change-check.yml | 7 ++++--- workflows/schema-change-check.wac.ts | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/schema-change-check.yml b/.github/workflows/schema-change-check.yml index b799450..1b7f517 100644 --- a/.github/workflows/schema-change-check.yml +++ b/.github/workflows/schema-change-check.yml @@ -79,13 +79,14 @@ jobs: with: script: |- const { repo, owner } = context.repo; - const pulls = await github.rest.pulls.list({ + // The `head` filter of pulls.list only matches an exact branch name, so list all open PRs and filter by prefix. + const pulls = await github.paginate(github.rest.pulls.list, { owner, repo, state: 'open', - head: `${owner}:chore/schema-update-` + per_page: 100, }); - const schemaUpdatePRs = pulls.data.filter(pr => pr.head.ref.startsWith('chore/schema-update-')); + const schemaUpdatePRs = pulls.filter(pr => pr.head.ref.startsWith('chore/schema-update-')); if (schemaUpdatePRs.length > 0) { console.log(`Found existing schema update PR: ${schemaUpdatePRs[0].html_url}`); core.setOutput('exists', 'true'); diff --git a/workflows/schema-change-check.wac.ts b/workflows/schema-change-check.wac.ts index b95a57f..a7c75d2 100644 --- a/workflows/schema-change-check.wac.ts +++ b/workflows/schema-change-check.wac.ts @@ -79,13 +79,14 @@ const checkExistingPR = new Step({ with: { script: dedentString(` const { repo, owner } = context.repo; - const pulls = await github.rest.pulls.list({ + // The \`head\` filter of pulls.list only matches an exact branch name, so list all open PRs and filter by prefix. + const pulls = await github.paginate(github.rest.pulls.list, { owner, repo, state: 'open', - head: \`\${owner}:chore/schema-update-\` + per_page: 100, }); - const schemaUpdatePRs = pulls.data.filter(pr => pr.head.ref.startsWith('chore/schema-update-')); + const schemaUpdatePRs = pulls.filter(pr => pr.head.ref.startsWith('chore/schema-update-')); if (schemaUpdatePRs.length > 0) { console.log(\`Found existing schema update PR: \${schemaUpdatePRs[0].html_url}\`); core.setOutput('exists', 'true');