Skip to content

Commit 9a6b256

Browse files
authored
Merge pull request #46 from ldetmer/fix-pr
fix: check PR status
2 parents 1e1780a + 48dd684 commit 9a6b256

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

pr-ready/pr-ready.sh

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@ get_release_prs() {
55
local token=$1
66
local repo=$2
77
local desc=$3
8-
local response=$(curl -s -H "Authorization: token $token" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/$repo/pulls")
9-
# Extract PR numbers from the response JSON
10-
echo "$response" | jq -r '.[] | select(.title | startswith("$desc")) | .number'
11-
12-
PR_NUMBER=$(echo "$response" | jq -r '.[] | select(.title | startswith("$desc")) | .number')
13-
14-
if [ -n "$PR_NUMBER" ]; then
15-
echo "$PR_NUMBER"
16-
return 0 # PR found
17-
else
18-
echo "No PR found starting with '$desc'. Trying again in 60 seconds..."
19-
sleep 60
20-
return 1 # PR not found
21-
fi
8+
while true; do
9+
local response=$(curl -s -H "Authorization: token $token" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/$repo/pulls")
10+
# Extract PR numbers from the response JSON
11+
echo "$response" | jq -r '.[] | select(.title | startswith("'$desc'")) | .number'
12+
13+
PR_NUMBER=$(echo "$response" | jq -r '.[] | select(.title | startswith("'$desc'")) | .number')
14+
15+
if [ -n "$PR_NUMBER" ]; then
16+
echo "$PR_NUMBER"
17+
return 0 # PR found
18+
else
19+
#echo "No PR found starting with '$desc'. Trying again in 60 seconds..."
20+
sleep 60
21+
fi
22+
done
2223
}
2324

2425
# Function to merge a PR
@@ -49,7 +50,7 @@ TOKEN=$1
4950
REPO=$2
5051
DESC=$3
5152

52-
release_prs=$(get_release_prs "$TOKEN" "$REPO" "$DESC")
53+
release_prs=$(get_release_prs "$TOKEN" "$REPO" "$DESC"); do
5354

5455
# Iterate over PR numbers and attempt to merge them
5556
for pr_number in $release_prs; do

0 commit comments

Comments
 (0)