Finalize with check-runs only
This commit is contained in:
parent
36e75b1b69
commit
18fbf900ed
|
@ -10,12 +10,13 @@ fi
|
||||||
|
|
||||||
if [ -z "${2}" ]; then
|
if [ -z "${2}" ]; then
|
||||||
echo "No PR# specified, here is a list:"
|
echo "No PR# specified, here is a list:"
|
||||||
curl -s --request GET -u ${1} ${REPOAPIURL}/pulls \
|
curl -s -X GET -u ${1} ${REPOAPIURL}/pulls \
|
||||||
| jq '.[] | select(.state == "open") | .number, .title' | paste - -
|
| jq '.[] | select(.state == "open") | .number, .title' | paste - -
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pr=$(curl -s --request GET -u ${1} ${REPOAPIURL}/pulls/${2})
|
# Read PR and parse its fields
|
||||||
|
pr=$(curl -s -X GET -u ${1} ${REPOAPIURL}/pulls/${2})
|
||||||
|
|
||||||
branch=$(echo $pr | jq '.head | (.repo.ssh_url + " " + .label)' | tr -d '"')
|
branch=$(echo $pr | jq '.head | (.repo.ssh_url + " " + .label)' | tr -d '"')
|
||||||
title=$(echo $pr | jq '.title')
|
title=$(echo $pr | jq '.title')
|
||||||
|
@ -24,10 +25,13 @@ body=$(echo $pr | jq '.body')
|
||||||
|
|
||||||
echo "Merging PR ${2}"
|
echo "Merging PR ${2}"
|
||||||
|
|
||||||
|
# Merge PR branch into the newly created branch and push it to github
|
||||||
|
git checkout v0.6
|
||||||
git branch -d gitea-${2}
|
git branch -d gitea-${2}
|
||||||
git checkout -b gitea-${2} v0.6
|
git checkout -b gitea-${2} v0.6
|
||||||
git pull ${branch} || exit 1
|
git pull ${branch} || exit 1
|
||||||
git push --set-upstream origin gitea-${2}
|
git push --set-upstream origin gitea-${2}
|
||||||
|
git checkout v0.6
|
||||||
|
|
||||||
if [ -z "${3}" ]; then
|
if [ -z "${3}" ]; then
|
||||||
echo "No github credentials specified, stopping"
|
echo "No github credentials specified, stopping"
|
||||||
|
@ -38,21 +42,49 @@ head=$(echo ${3} | cut -d: -f1):gitea-${2}
|
||||||
|
|
||||||
REPOAPIURL=https://api.github.com/repos/Bitmessage/PyBitmessage
|
REPOAPIURL=https://api.github.com/repos/Bitmessage/PyBitmessage
|
||||||
|
|
||||||
|
# Create PR on github and parse its fields
|
||||||
pr=$(curl -s -u ${3} -X POST \
|
pr=$(curl -s -u ${3} -X POST \
|
||||||
-H "Accept: application/vnd.github.v3+json" ${REPOAPIURL}/pulls \
|
-H "Accept: application/vnd.github.v3+json" ${REPOAPIURL}/pulls \
|
||||||
-d "{\"title\":${title},\"body\":${body},\"head\":\"${head}\",\"base\":\"${upstream}\"}")
|
-d "{\"title\":${title},\"body\":${body},\"head\":\"${head}\",\"base\":\"${upstream}\"}")
|
||||||
|
|
||||||
# commit=$(echo $pr | jq '.head.sha')
|
commit=$(echo $pr | jq '.head.sha' | tr -d '"')
|
||||||
# url=$(echo $pr | jq '.url')
|
branch=(echo $pr | jq '.base.ref' | tr -d '"')
|
||||||
|
url=$(echo $pr | jq '.url' | tr -d '"')
|
||||||
|
|
||||||
# checks=$(
|
|
||||||
# curl -s --request GET \
|
|
||||||
# -H "Accept: application/vnd.github.v3+json" \
|
|
||||||
# ${REPOAPIURL}/commits/${commit}/check-runs)
|
|
||||||
|
|
||||||
# sleep 10
|
# Return non-zero status if have a check with conclusion other than "success"
|
||||||
|
pr_status () {
|
||||||
|
checks=$(
|
||||||
|
curl -s -X GET \
|
||||||
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
|
${REPOAPIURL}/commits/${1}/check-runs)
|
||||||
|
if [[ \
|
||||||
|
$(echo $checks | jq \
|
||||||
|
'(.check_runs | map(select(.conclusion == "success")) | length) == .total_count'\
|
||||||
|
) != true ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# echo $checks | jq '(.check_runs | map(select(.conclusion == "success")) | length) == .total_count'
|
# Invoke pullrequest.sh script if pr_status is 0 within 30 tries in 5 min
|
||||||
|
for tick in {1..30}; do
|
||||||
|
sleep 10
|
||||||
|
pr_status ${commit}
|
||||||
|
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
./git-tools.sh mergepullrequest $(curl -s -X GET ${url} | jq '.number')
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# curl -s -X GET ${REPOAPIURL}/commits/${commit}/status
|
||||||
|
|
||||||
# curl -s -u ${3} -X POST \
|
# curl -s -u ${3} -X POST \
|
||||||
# -H "Accept: application/vnd.github.v3+json" $url -d '{"event":"APPROVE"}'
|
# -H "Accept: application/vnd.github.v3+json" $url/reviews \
|
||||||
|
# -d '{"event":"APPROVE"}'
|
||||||
|
# "Can not approve your own pull request"
|
||||||
|
|
||||||
|
# Delete branch:
|
||||||
|
# curl -s -u ${3} -X DELETE -H "Accept: application/vnd.github.v3+json" \
|
||||||
|
# ${REPOAPIURL}/git/refs/heads/gitea-${2}
|
||||||
|
|
Loading…
Reference in New Issue