From 7d0d42e5025138c69a1e6dba0b1f0d5c1ca8ca06 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Fri, 9 May 2025 06:34:11 +0000 Subject: [PATCH] fix(github-actions): delete obsolete branches and close superseded PRs When using the `create-pr-for-changes` workflow, old branches are not being deleted, and the content of superseded PRs remains open. This change ensures that: - Obsolete branches are deleted after PR creation. - Previously created PRs with outdated content are automatically closed. Example: https://github.com/angular/angular/pull/61203 --- github-actions/create-pr-for-changes/lib/main.ts | 2 ++ github-actions/create-pr-for-changes/main.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/github-actions/create-pr-for-changes/lib/main.ts b/github-actions/create-pr-for-changes/lib/main.ts index 46f59e322..916b3f54e 100644 --- a/github-actions/create-pr-for-changes/lib/main.ts +++ b/github-actions/create-pr-for-changes/lib/main.ts @@ -129,6 +129,7 @@ async function main(): Promise { const { data: {items: supersededPrs}, } = await git.github.search.issuesAndPullRequests({ + advanced_search: 'true', q: toGithubSearchQuery({ repo: `${repo.owner}/${repo.name}`, type: 'pull-request', @@ -276,6 +277,7 @@ async function cleanUpObsoleteBranches( const { data: {items: obsoletePrs}, } = await git.github.search.issuesAndPullRequests({ + advanced_search: 'true', q: toGithubSearchQuery({ repo: `${repo.owner}/${repo.name}`, type: 'pull-request', diff --git a/github-actions/create-pr-for-changes/main.js b/github-actions/create-pr-for-changes/main.js index f2b2d86bc..af7df1a40 100644 --- a/github-actions/create-pr-for-changes/main.js +++ b/github-actions/create-pr-for-changes/main.js @@ -47995,6 +47995,7 @@ async function main() { core.info(`No pre-existing PR found for branch '${branchName}'.`); } const { data: { items: supersededPrs } } = await git.github.search.issuesAndPullRequests({ + advanced_search: "true", q: toGithubSearchQuery({ repo: `${repo.owner}/${repo.name}`, type: "pull-request", @@ -48073,6 +48074,7 @@ ${prBody}`; } async function cleanUpObsoleteBranches(git, repo, forkRepo, branchPrefix) { const { data: { items: obsoletePrs } } = await git.github.search.issuesAndPullRequests({ + advanced_search: "true", q: toGithubSearchQuery({ repo: `${repo.owner}/${repo.name}`, type: "pull-request",