File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Set your GitHub repository
4+ REPO=" ldetmer/java-cloud"
5+
6+ # Function to fetch release PRs
7+ get_release_prs () {
8+ local token=$1
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("chore(main): release")) | .number'
12+ }
13+
14+ # Function to merge a PR
15+ merge_pr () {
16+ local pr_number=$1
17+ local token=$2
18+ while true ; do
19+ local response=$( curl -s -H " Authorization: token $token " -H " Accept: application/vnd.github+json" " https://api.github.com/repos/$REPO /pulls/$pr_number " )
20+ # Check if the PR is mergeable
21+ if jq -e ' .mergeable' <<< " $response" > /dev/null; then
22+ _PR = " https://api.github.com/repos/$REPO /pulls/$pr_number "
23+ ${_PR} = " https://api.github.com/repos/$REPO /pulls/$pr_number "
24+ else
25+ echo " PR #$pr_number is not mergeable"
26+ sleep 60
27+ fi
28+ done
29+ }
30+
31+ # Main script execution
32+ if [[ $# -ne 1 ]]; then
33+ echo " Usage: $0 <your-github-access-token>"
34+ exit 1
35+ fi
36+
37+ TOKEN=$1
38+ release_prs=$( get_release_prs " $TOKEN " )
39+
40+ # Iterate over PR numbers and attempt to merge them
41+ for pr_number in $release_prs ; do
42+ merge_pr " $pr_number " " $TOKEN "
43+ done
You can’t perform that action at this time.
0 commit comments