We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 133f3a1 commit 3101303Copy full SHA for 3101303
1 file changed
pr-ready/wait-for-merge.sh
@@ -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
15
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