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.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2025-01-22 10:10:45 -03:00 committed by GitHub
commit 16448e4247
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: