Skip to content

Commit 6edea08

Browse files
authored
Merge pull request #21 from ldetmer/wait-for-merge
feat: add script to wait for PR to merge
2 parents 133f3a1 + 3101303 commit 6edea08

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pr-ready/wait-for-merge.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# Get the API URL as an argument
4+
if [ -z "$1" ]; then
5+
echo "Usage: $0 <API_URL>"
6+
exit 1
7+
fi
8+
API_URL="$1"
9+
10+
# Get the GitHub token from an environment variable
11+
GITHUB_TOKEN="${GITHUB_TOKEN:-}"
12+
if [ -z "$GITHUB_TOKEN" ]; then
13+
echo "Error: GITHUB_TOKEN environment variable not set."
14+
exit 1
15+
fi
16+
17+
# Function to check the merge status
18+
check_pr_status() {
19+
PR_DATA=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$API_URL")
20+
if echo "$PR_DATA" | grep -q '"merged": true'; then
21+
echo "Pull request is merged."
22+
return 0
23+
else
24+
echo "Pull request is not merged. Checking again in 60 seconds..."
25+
sleep 60
26+
return 1
27+
fi
28+
}
29+
30+
# Keep checking until the PR is merged
31+
while check_pr_status; do
32+
:
33+
done

0 commit comments

Comments
 (0)