Skip to content

Commit f52b16d

Browse files
committed
Clean up old PRs from same run
We use the run id in our branch name. If we have a failure (real, transient, whatever) and retry the task on the same run id, we run into issues because the PR from the previous attempt still exists.
1 parent 9a3eec0 commit f52b16d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

github/create-pull-request/rwx-ci-cd.template.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
- key: gh-cli
22
call: github/install-cli 1.0.8
33

4+
- key: cleanup-previous-run
5+
use: gh-cli
6+
run: |
7+
branch="${RUN_ID}-${RUN_ID}"
8+
existing_pr=$(gh --repo rwx-cloud/mint-update-leaves-testing pr list --head "$branch" --json number --jq '.[0].number')
9+
if [ -n "$existing_pr" ]; then
10+
echo "Closing leftover PR #$existing_pr from previous failed attempt"
11+
gh --repo rwx-cloud/mint-update-leaves-testing pr close "$existing_pr" --delete-branch || true
12+
fi
13+
env:
14+
GITHUB_TOKEN: ${{ github-apps.rwx-cloud-bot.token }}
15+
RUN_ID: ${{ run.id }}
16+
417
- key: code
518
call: git/clone 2.0.0
619
with:
@@ -32,6 +45,7 @@
3245
touch "$file"
3346
3447
- key: create-pr
48+
after: cleanup-previous-run
3549
call: $LEAF_DIGEST
3650
use: code-change
3751
with:

0 commit comments

Comments
 (0)