-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
76 lines (64 loc) · 1.79 KB
/
entrypoint.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
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
set -e
DEBUG="${INPUT_DEBUG}"
if [[ X"$DEBUG" == X"true" ]]; then
set -x
DEBUG="true"
else
DEBUG="false"
fi
FORCE_UPDATE="${INPUT_FORCE_UPDATE}"
if [[ X"$FORCE_UPDATE" == X"true" ]]; then
FORCE_UPDATE="true"
else
FORCE_UPDATE="false"
fi
echo "## Check User ##################"
whoami
echo "## Check Package Version ##################"
bash --version
git version
git lfs version
git-mirrors -v
echo "## Init Git Config ##################"
git config --global --add safe.directory /github/workspace/${PUBLISH_DIR}
echo "## Setup Deploy keys ##################"
[ -d /root/.ssh ] || mkdir /root/.ssh
if [ X"$INPUTE_SSH_KEYSCANS" = X"" ]; then
INPUTE_SSH_KEYSCANS="github.com,gitee.com"
fi
KNOWN_HOSTS="/root/.ssh/known_hosts"
GIT_HOST_ARRAY=(${INPUTE_SSH_KEYSCANS//,/ })
for host in ${GIT_HOST_ARRAY[@]}; do
# ssh-keyscan -t rsa $host >> ${KNOWN_HOSTS}
# ssh-keyscan -t ecdsa $host >> ${KNOWN_HOSTS}
ssh-keyscan $host >> ${KNOWN_HOSTS}
done
cat ${KNOWN_HOSTS}
export SSH_KNOWN_HOSTS="${KNOWN_HOSTS}"
DST_KEY=""
if [ X"$INPUT_DST_KEY" = X"" ]; then
echo "## Skip ssh key deploy ##################"
else
DST_KEY="/root/.ssh/git_key"
echo "${INPUT_DST_KEY}" > ${DST_KEY}
chmod 400 ${DST_KEY}
ls -lhart ${DST_KEY}
fi
echo "## begin sync ##################"
git-mirrors \
--src "${INPUT_SRC}" \
--src-token "${INPUT_SRC_TOKEN}" \
--dst "${INPUT_DST}" \
--dst-key "${DST_KEY}" \
--dst-token "${INPUT_DST_TOKEN}" \
--account-type "${INPUT_ACCOUNT_TYPE}" \
--clone-style "${INPUT_CLONE_STYLE}" \
--cache-path "${INPUT_CACHE_PATH}" \
--black-list "${INPUT_BLACK_LIST}" \
--white-list "${INPUT_WHITE_LIST}" \
--force-update="${FORCE_UPDATE}" \
--debug="${DEBUG}" \
--timeout "${INPUT_TIMEOUT}" \
--mappings "${INPUT_MAPPINGS}"
echo "## Done. ##################"