-
Notifications
You must be signed in to change notification settings - Fork 229
/
start.sh
65 lines (52 loc) · 1.66 KB
/
start.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
60
61
62
63
64
65
#!/bin/sh
set -e
INPUT_ATOMIC=${INPUT_ATOMIC:-true}
INPUT_FORCE=${INPUT_FORCE:-false}
INPUT_FORCE_WITH_LEASE=${INPUT_FORCE_WITH_LEASE:-false}
INPUT_SSH=${INPUT_SSH:-false}
INPUT_TAGS=${INPUT_TAGS:-false}
INPUT_PUSH_ONLY_TAGS=${INPUT_PUSH_ONLY_TAGS:-false}
INPUT_DIRECTORY=${INPUT_DIRECTORY:-"."}
INPUT_PUSH_TO_SUBMODULES=${INPUT_PUSH_TO_SUBMODULES:-""}
_ATOMIC_OPTION=""
_FORCE_OPTION=""
REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}
echo "Push to branch $INPUT_BRANCH";
[ -z "${INPUT_GITHUB_TOKEN}" ] && {
echo "Missing input 'github_token: ${{ secrets.GITHUB_TOKEN }}'.";
exit 1;
};
if ${INPUT_FORCE} && ${INPUT_FORCE_WITH_LEASE}; then
echo "Please, specify only force or force_with_lease and not both.";
exit 1;
fi
if ${INPUT_ATOMIC}; then
_ATOMIC_OPTION="--atomic"
fi
if ${INPUT_FORCE}; then
_FORCE_OPTION="--force"
fi
if ${INPUT_FORCE_WITH_LEASE}; then
_FORCE_OPTION="--force-with-lease"
fi
if ${INPUT_TAGS}; then
_TAGS="--tags"
fi
if [ -n "${INPUT_PUSH_TO_SUBMODULES}" ]; then
_INPUT_PUSH_TO_SUBMODULES="--recurse-submodules=${INPUT_PUSH_TO_SUBMODULES}"
fi
cd ${INPUT_DIRECTORY}
if ${INPUT_SSH}; then
remote_repo="git@${INPUT_GITHUB_URL}:${REPOSITORY}.git"
else
remote_repo="${INPUT_GITHUB_URL_PROTOCOL}//oauth2:${INPUT_GITHUB_TOKEN}@${INPUT_GITHUB_URL}/${REPOSITORY}.git"
fi
if ! ${INPUT_FORCE_WITH_LEASE}; then
ADDITIONAL_PARAMETERS="${remote_repo} HEAD:${INPUT_BRANCH}"
elif ${INPUT_PUSH_ONLY_TAGS}; then
ADDITIONAL_PARAMETERS="${remote_repo}"
fi
if ${INPUT_FORCE_WITH_LEASE} && ${INPUT_TAGS}; then
_ATOMIC_OPTION=""
fi
git push $ADDITIONAL_PARAMETERS $_INPUT_PUSH_TO_SUBMODULES $_ATOMIC_OPTION --follow-tags $_FORCE_OPTION $_TAGS;