-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
54 lines (36 loc) · 1.36 KB
/
docker-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
#!/bin/bash
echo;echo
if [ -n "$PCIT" ];then
PCIT_USERNAME=$INPUT_USERNAME
PCIT_TARGET_BRANCH=$INPUT_TARGET_BRANCH
PCIT_GIT_URL=$INPUT_GIT_URL
PCIT_LOCAL_DIR=$INPUT_LOCAL_DIR
PCIT_EMAIL=$INPUT_EMAIL
PCIT_KEEP_HISTORY=$INPUT_KEEP_HISTORY
PCIT_GIT_TOKEN=$INPUT_GIT_TOKEN
PCIT_MESSAGE=$INPUT_MESSAGE
fi
echo "==> Preparing deploy git pages"
set -ex
if ! [ -d ${PCIT_LOCAL_DIR} ];then exit; fi
rm -rf ${PCIT_LOCAL_DIR}/.git
if [ ${PCIT_KEEP_HISTORY:-'false'} = 'true' ];then
git clone --bare -b ${PCIT_TARGET_BRANCH:-gh-pages} https://${PCIT_GIT_URL} ${PCIT_LOCAL_DIR}/.git || true
fi
cd ${PCIT_LOCAL_DIR}
# 原始仓库不存在(分支不存在)
if ! [ -d .git ];then
new=true
fi
git init
git add .
git config user.name ${PCIT_USERNAME:-pcit-ce}
git config user.email ${PCIT_EMAIL:[email protected]}
git commit -m "${PCIT_MESSAGE:-"Deploy Git by PCIT https://ci.khs1994.com"}" || exit 0
set +e; git remote get-url origin && git remote rm origin; set -e
set +x
echo "git remote add origin https://${PCIT_USERNAME:-pcit-ce}:PCIT_GIT_TOKEN@${PCIT_GIT_URL}.git"
git remote add origin https://${PCIT_USERNAME:-pcit-ce}:${PCIT_GIT_TOKEN}@${PCIT_GIT_URL}.git
set -x
if [ ${new:-false} == 'true' ];then git push origin master:${PCIT_TARGET_BRANCH:-gh-pages} -f ; exit 0; fi
git push origin ${PCIT_TARGET_BRANCH:-gh-pages}:${PCIT_TARGET_BRANCH:-gh-pages} -f || true