forked from CodeChain-io/codechain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-mergify-merge
executable file
·53 lines (47 loc) · 1.32 KB
/
check-mergify-merge
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
#!/usr/bin/env bash
# Everything that is normally printed to `stdout` in the script will be redirected to `stderr`
# which will be visible in tty/Travis log.
# Outputs that is printed to `fd 3` will be redirected to `stdout`,
# which will be finally assigned to a variable `$SKIP`
exec 3>&1 1>&2 # fd 3 = fd 1; fd 1 = fd 2
function return_to_travis {
STRATEGY="${1}"
echo "${STRATEGY}" >&3
exit 0
}
function skip_travis { return_to_travis "skip" ; }
function noskip_travis { return_to_travis "noskip" ; }
echo "TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE}"
echo "TRAVIS_BRANCH=${TRAVIS_BRANCH}"
echo "TRAVIS_COMMIT=${TRAVIS_COMMIT}"
set -xe
case ${TRAVIS_EVENT_TYPE} in
push)
if [[ "${TRAVIS_BRANCH}" = master ]]
then
echo "Push on master"
else
echo "Don't skip testing for other than master"
noskip_travis
fi
;;
*)
echo "Don't skip for PR, api, cron event"
noskip_travis
;;
esac
MERGIFY_COMMITTER="mergify[bot] <mergify[bot]@users.noreply.github.com>"
COMMITTER=$(git show --format="%cN <%cE>" --no-patch "${TRAVIS_COMMIT}")
RESULT=$?
if [[ "$RESULT" -ne 0 ]]
then
echo "Error: cannot get the committer"
exit $RESULT
fi
if [[ "${COMMITTER}" = "${MERGIFY_COMMITTER}" ]]
then
echo "Skip check since it was checked in other PR"
skip_travis
else
noskip_travis
fi