Close old pull request on target branch

I am creating a pull request using action, but before that I want to close all pull request opened against main branch with label auto-pr.

Any solution for this?

:wave: @tbhaxor, I think using the github-script action might help here

It contains an authenticated Octokit client, which you can use to fetch all of the pull requests in your repository with that label and then close them.

There are examples in the README for the github-script action.

The steps you’d want are:

  1. List all pull requests with target branch main - https://octokit.github.io/rest.js/v18#pulls-list
  2. Filter that list to the pull requests with the auto-pr label
  3. Close the pull request by updating the state to closed - https://octokit.github.io/rest.js/v18#pulls-update