-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddsExtraCommitForMR.sh
executable file
·59 lines (56 loc) · 1.77 KB
/
addsExtraCommitForMR.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
user=$1
pages=$2
org=$3
porg=$4
user=${user:=jesperancinha}
pages=${pages:=100}
org=${org:=jesperancinhaOrg}
porg=${porg:=100}
echo -e '\e[31mWARNING!!\e[0m'
echo -e "\e[32mCarefull when using this script! It will push an extra commit to automated merge requests\e[0m"
echo -e "\e[32mExample usage: ./startMergeAll.sh $user $pages $org $porg\e[0m"
read -p "Are you sure? (Yy/Nn)" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
repos=$(curl https://api.github.com/users/"${user}"/repos?per_page="${pages}")
echo "$repos"
cd ..
for row in $(echo "${repos}" | jq -r '.[] | @base64'); do
_jq() {
echo "${row}" | base64 --decode | jq -r "${1}"
}
if [[ $(_jq '.fork') =~ ^'false'$ ]]; then
repoAddress=$(_jq '.name')
echo "${repoAddress}"
if [ -d "${repoAddress}" ]; then
cd "${repoAddress}" || exit
git pull
git fetch -p
curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/jesperancinha/buy-odd-yucca-concert/pulls?state=open" | jq '.[] | .head.ref' | grep "update-" | xargs -I {} git checkout {} && git pull && make accept-prs
git checkout main &
git checkout master &
# shellcheck disable=SC2103
cd ..
fi
fi
sleep 1
done
repos=$(curl https://api.github.com/orgs/"${org}"/repos?per_page="${porg}")
echo "$repos"
for row in $(echo "${repos}" | jq -r '.[] | @base64'); do
_jq2() {
echo "${row}" | base64 --decode | jq -r "${1}"
}
if [[ $(_jq2 '.fork') =~ ^'false'$ ]]; then
repoAddress=$(_jq2 '.name')
echo "${repoAddress}"
if [ -d "${repoAddress}" ]; then
cd "${repoAddress}" || exit
# shellcheck disable=SC2103
cd ..
fi
fi
sleep 1
done
cd project-signer || exit
fi