parent
6ae0084255
commit
a181e8e7d8
|
@ -4,6 +4,12 @@
|
||||||
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
|
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
|
||||||
set -u -e -E -o pipefail
|
set -u -e -E -o pipefail
|
||||||
|
|
||||||
|
BOLD='printf \e[1m'
|
||||||
|
RESET_STYLES='printf \e[0m'
|
||||||
|
LIGHT_CYAN='printf \e[96m'
|
||||||
|
LIGHT_MAGENTA='printf \e[95m'
|
||||||
|
GREEN='printf \e[32m'
|
||||||
|
RED='printf \e[31m'
|
||||||
|
|
||||||
BASEDIR=$(dirname "$0")
|
BASEDIR=$(dirname "$0")
|
||||||
BASEDIR=`(cd $BASEDIR; pwd)`
|
BASEDIR=`(cd $BASEDIR; pwd)`
|
||||||
|
@ -42,11 +48,13 @@ if [ "$PR_NUMBER" -eq 0 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${TOKEN:-''} ]; then
|
if [ -z ${TOKEN:-''} ]; then
|
||||||
|
$RED
|
||||||
echo "############################################################"
|
echo "############################################################"
|
||||||
echo "############################################################"
|
echo "############################################################"
|
||||||
echo "WARNING: you should set the TOKEN variable to a github token"
|
echo "WARNING: you should set the TOKEN variable to a github token"
|
||||||
echo "############################################################"
|
echo "############################################################"
|
||||||
echo "############################################################"
|
echo "############################################################"
|
||||||
|
$RESET_STYLES
|
||||||
GH_AUTH=""
|
GH_AUTH=""
|
||||||
else
|
else
|
||||||
GH_AUTH="Authorization: token $TOKEN"
|
GH_AUTH="Authorization: token $TOKEN"
|
||||||
|
@ -63,21 +71,28 @@ PR_CLA=`echo "$PR_LABELS" | node $BASEDIR/utils/json_extract.js "name=^cla"`
|
||||||
MASTER_BRANCH='master'
|
MASTER_BRANCH='master'
|
||||||
|
|
||||||
if [[ ! "$PR_ACTION" =~ "PR action: merge" ]]; then
|
if [[ ! "$PR_ACTION" =~ "PR action: merge" ]]; then
|
||||||
|
$RED
|
||||||
echo The PR is missing 'PR action: merge(-assistance)' label, found: $PR_ACTION
|
echo The PR is missing 'PR action: merge(-assistance)' label, found: $PR_ACTION
|
||||||
|
$RESET_STYLES
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$PR_CLA" != "cla: yes" ]]; then
|
if [[ "$PR_CLA" != "cla: yes" ]]; then
|
||||||
|
$RED
|
||||||
echo The PR is missing 'cla: Yes' label, found: $PR_CLA
|
echo The PR is missing 'cla: Yes' label, found: $PR_CLA
|
||||||
|
$RESET_STYLES
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$STATUS" != "All checks passed!" ]]; then
|
if [[ "$STATUS" != "All checks passed!" ]]; then
|
||||||
echo PR $PR_NUMBER is failing with: $STATUS
|
echo PR $PR_NUMBER is failing with: $STATUS
|
||||||
if [[ $FORCE == 1 ]]; then
|
if [[ $FORCE == 1 ]]; then
|
||||||
|
$BOLD
|
||||||
|
$LIGHT_MAGENTA
|
||||||
echo FORCING: --force flag used to ignore PR status.
|
echo FORCING: --force flag used to ignore PR status.
|
||||||
|
$RESET_STYLES
|
||||||
else
|
else
|
||||||
echo Exting...
|
echo Exiting...
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -92,7 +107,9 @@ elif [[ $PR_TARGET == "PR target: patch-only" ]]; then
|
||||||
MERGE_MASTER=0
|
MERGE_MASTER=0
|
||||||
MERGE_PATCH=1
|
MERGE_PATCH=1
|
||||||
else
|
else
|
||||||
|
$RED
|
||||||
echo "Unknown PR target format: $PR_TARGET"
|
echo "Unknown PR target format: $PR_TARGET"
|
||||||
|
$RESET_STYLES
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -124,6 +141,8 @@ elif [[ $MERGE_PATCH == 1 ]]; then
|
||||||
fi
|
fi
|
||||||
CHECK_IF_PR_REBASED="git branch --quiet merge_pr --contains $REQUIRED_BASE_SHA"
|
CHECK_IF_PR_REBASED="git branch --quiet merge_pr --contains $REQUIRED_BASE_SHA"
|
||||||
|
|
||||||
|
$BOLD
|
||||||
|
$LIGHT_CYAN
|
||||||
echo "======================"
|
echo "======================"
|
||||||
echo "GitHub Merge PR Steps"
|
echo "GitHub Merge PR Steps"
|
||||||
echo "======================"
|
echo "======================"
|
||||||
|
@ -141,46 +160,76 @@ fi
|
||||||
echo " $PUSH_BRANCHES"
|
echo " $PUSH_BRANCHES"
|
||||||
echo " $RESTORE_BRANCH"
|
echo " $RESTORE_BRANCH"
|
||||||
echo "----------------------"
|
echo "----------------------"
|
||||||
|
$RESET_STYLES
|
||||||
|
$BOLD
|
||||||
|
echo ""
|
||||||
echo ">>> Fetch PR: $FETCH_PR"
|
echo ">>> Fetch PR: $FETCH_PR"
|
||||||
|
$RESET_STYLES
|
||||||
$FETCH_PR
|
$FETCH_PR
|
||||||
|
$BOLD
|
||||||
|
echo ""
|
||||||
echo ">>> Mark base: $BASE_PR"
|
echo ">>> Mark base: $BASE_PR"
|
||||||
|
$RESET_STYLES
|
||||||
$BASE_PR
|
$BASE_PR
|
||||||
|
$BOLD
|
||||||
|
echo ""
|
||||||
echo ">>> Check if PR rebased: $CHECK_IF_PR_REBASED"
|
echo ">>> Check if PR rebased: $CHECK_IF_PR_REBASED"
|
||||||
|
$RESET_STYLES
|
||||||
if [[ $($CHECK_IF_PR_REBASED) != "" ]]; then
|
if [[ $($CHECK_IF_PR_REBASED) != "" ]]; then
|
||||||
|
$GREEN
|
||||||
echo "The PR is sufficiently rebased!"
|
echo "The PR is sufficiently rebased!"
|
||||||
|
$RESET_STYLES
|
||||||
else
|
else
|
||||||
|
$RED
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
echo "Failed to merge pull request #${PR_NUMBER} because it hasn't been rebased recently and could be bypassing new or updated CI checks!"
|
echo "Failed to merge pull request #${PR_NUMBER} because it hasn't been rebased recently and could be bypassing new or updated CI checks!"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Please rebase the PR and try again."
|
echo "Please rebase the PR and try again."
|
||||||
echo ""
|
echo ""|
|
||||||
|
$RESET_STYLES
|
||||||
$RESTORE_BRANCH
|
$RESTORE_BRANCH
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
$BOLD
|
||||||
|
echo ""
|
||||||
echo ">>> Autosquash: $SQUASH_PR"
|
echo ">>> Autosquash: $SQUASH_PR"
|
||||||
|
$RESET_STYLES
|
||||||
GIT_EDITOR=echo $SQUASH_PR
|
GIT_EDITOR=echo $SQUASH_PR
|
||||||
|
$BOLD
|
||||||
|
echo ""
|
||||||
echo ">>> Rewrite message: $REWRITE_MESSAGE"
|
echo ">>> Rewrite message: $REWRITE_MESSAGE"
|
||||||
# Next line should work, but it errors, hence copy paste the command.
|
# Next line should work, but it errors, hence copy paste the command.
|
||||||
# $REWRITE_MESSAGE
|
# $REWRITE_MESSAGE
|
||||||
|
$RESET_STYLES
|
||||||
git filter-branch -f --msg-filter "$BASEDIR/utils/github_closes.js $PR_NUMBER" merge_pr_base..merge_pr
|
git filter-branch -f --msg-filter "$BASEDIR/utils/github_closes.js $PR_NUMBER" merge_pr_base..merge_pr
|
||||||
if [[ $MERGE_MASTER == 1 ]]; then
|
if [[ $MERGE_MASTER == 1 ]]; then
|
||||||
|
$BOLD
|
||||||
echo
|
echo
|
||||||
echo ">>> Cherry pick to master: $CHECKOUT_MASTER && $CHERRY_PICK_PR"
|
echo ">>> Cherry pick to master: $CHECKOUT_MASTER && $CHERRY_PICK_PR"
|
||||||
|
$RESET_STYLES
|
||||||
$CHECKOUT_MASTER
|
$CHECKOUT_MASTER
|
||||||
$CHERRY_PICK_PR
|
$CHERRY_PICK_PR
|
||||||
fi
|
fi
|
||||||
if [[ $MERGE_PATCH == 1 ]]; then
|
if [[ $MERGE_PATCH == 1 ]]; then
|
||||||
|
$BOLD
|
||||||
echo
|
echo
|
||||||
echo ">>> Cherry pick to path: $CHECKOUT_PATCH && $CHERRY_PICK_PR"
|
echo ">>> Cherry pick to patch: $CHECKOUT_PATCH && $CHERRY_PICK_PR"
|
||||||
|
$RESET_STYLES
|
||||||
$CHECKOUT_PATCH
|
$CHECKOUT_PATCH
|
||||||
$CHERRY_PICK_PR
|
$CHERRY_PICK_PR
|
||||||
fi
|
fi
|
||||||
$RESTORE_BRANCH
|
$RESTORE_BRANCH
|
||||||
|
|
||||||
if [[ $PUSH_UPSTREAM == 1 ]]; then
|
if [[ $PUSH_UPSTREAM == 1 ]]; then
|
||||||
|
$BOLD
|
||||||
|
echo
|
||||||
echo ">>> Push branches to angular repo"
|
echo ">>> Push branches to angular repo"
|
||||||
|
$RESET_STYLES
|
||||||
$PUSH_BRANCHES
|
$PUSH_BRANCHES
|
||||||
fi
|
fi
|
||||||
|
$BOLD
|
||||||
|
$GREEN
|
||||||
echo
|
echo
|
||||||
echo ">>>>>> SUCCESS <<<<<< PR#$PR_NUMBER merged."
|
echo ">>>>>> SUCCESS <<<<<< PR#$PR_NUMBER merged."
|
||||||
|
$RESET_STYLES
|
||||||
|
|
Loading…
Reference in New Issue