Skip to content

Commit 4c5088f

Browse files
committed
ci(turbine): close existing PRs before creating new ones
1 parent 84327ae commit 4c5088f

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

build/scripts/turbine.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ git config user.email "github-actions[bot]@users.noreply.github.com"
1111
# Create new branch
1212
BRANCH_NAME="web-sdk-${SDK_VERSION}-release"
1313

14-
# Check if PR already exists
15-
EXISTING_PR=$(curl -s \
14+
# Close any existing PRs for this branch
15+
curl -s \
1616
-H "Authorization: Bearer $GH_TURBINE_TOKEN" \
1717
"https://api.github.com/repos/OneSignal/turbine/pulls?head=OneSignal:$BRANCH_NAME&state=open" |
18-
jq length)
19-
20-
if [ "$EXISTING_PR" -gt 0 ]; then
21-
echo "PR already exists for branch $BRANCH_NAME"
22-
exit 0
23-
fi
18+
jq -r '.[].number' | while read PR_NUM; do
19+
echo "Closing existing PR #$PR_NUM"
20+
curl -sS -X PATCH \
21+
-H "Authorization: Bearer $GH_TURBINE_TOKEN" \
22+
-H "Content-Type: application/json" \
23+
-d '{"state": "closed"}' \
24+
"https://api.github.com/repos/OneSignal/turbine/pulls/$PR_NUM"
25+
done
2426

2527
git checkout -B "$BRANCH_NAME"
2628

0 commit comments

Comments
 (0)