forked from sma11black/hexo-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
38 lines (32 loc) · 1.01 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
#!/bin/bash
set -e
# setup ssh-private-key
if [[ $INPUT_DEPLOY_KEY == ghp_* ]];then
echo "Using github token"
sed "s/GITHUB_TOKEN/$INPUT_DEPLOY_KEY/g" _config.yml >tmp && rm _config.yml && mv tmp _config.yml
else
mkdir -p /root/.ssh/
echo "$INPUT_DEPLOY_KEY" > /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa
ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts
fi
# setup deploy git account
git config --global user.name "$INPUT_USER_NAME"
git config --global user.email "$INPUT_USER_EMAIL"
# install hexo env
npm install hexo-cli -g
npm install hexo-deployer-git --save
# deployment
if [ "$INPUT_COMMIT_MSG" = "none" ]
then
hexo g -d
elif [ "$INPUT_COMMIT_MSG" = "" ] || [ "$INPUT_COMMIT_MSG" = "default" ]
then
# pull original publish repo
NODE_PATH=$NODE_PATH:$(pwd)/node_modules node /sync_deploy_history.js
hexo g -d
else
NODE_PATH=$NODE_PATH:$(pwd)/node_modules node /sync_deploy_history.js
hexo g -d -m "$INPUT_COMMIT_MSG"
fi
echo ::set-output name=notify::"Deploy complate."