logo头像

本地自动化部署网站

步骤

  1. source放入D盘(source为单独的git库)
  2. website放入D盘(为hexo项目文件夹)
  3. website目录下的source每次从1的远程仓库pull
  4. website下的source每次pull后删除title以【未完】开头的文件
  5. cd到website下hexo generate生成website下public文件夹
  6. cd到public文件夹下,将整个文件夹push到github page项目
  7. 完成!

本地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
#!/bin/bash

cd d:
SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
echo "current dir is ================>$SHELL_FOLDER"
cd source
time=$(date "+%Y-%m-%d %H:%M:%S")
echo $time
git status
git add .
git commit -m "modify ${time}"
git push

cd ..
SHELL_FOLDER2=$(cd "$(dirname "$0")";pwd)
echo "current dir is ================>$SHELL_FOLDER2"
cd website/source
SHELL_FOLDER3=$(cd "$(dirname "$0")";pwd)
echo "current dir is ================>$SHELL_FOLDER3"
git pull
find . -name "【未完】*" -exec rm -f {} \;
cd ..
hexo generate
cd public
SHELL_FOLDER4=$(cd "$(dirname "$0")";pwd)
echo "current dir is ================>$SHELL_FOLDER4"
git add .
git commit -m "modify ${time}"
git push
echo "Done!!!!!!"

配置Jenkins