From 16448e4247c2a7d65ff82efbfa4918f2dcea4da5 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 22 Jan 2025 10:10:45 -0300 Subject: [PATCH] ci: Automatically close existing PRs for test duration updates (#5852) ci: add step to close existing PRs before creating a new one for test duration updates - Introduced a new step in the GitHub Actions workflow to automatically close any open pull requests titled "chore: update test durations" before creating a new pull request. - This change ensures that only one pull request for updating test durations is active at a time, streamlining the workflow and reducing potential merge conflicts. --- .github/workflows/store_pytest_durations.yml | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/store_pytest_durations.yml b/.github/workflows/store_pytest_durations.yml index 7278b33d7..3d205e548 100644 --- a/.github/workflows/store_pytest_durations.yml +++ b/.github/workflows/store_pytest_durations.yml @@ -49,6 +49,28 @@ jobs: - name: Minimize uv cache run: uv cache prune --ci + - name: Close existing PRs + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: pulls } = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open' + }); + + for (const pull of pulls) { + if (pull.title === "chore: update test durations") { + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pull.number, + state: 'closed' + }); + } + } + - name: Create Pull Request uses: peter-evans/create-pull-request@v7 with: