-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (82 loc) · 2.72 KB
/
hexo.yml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: BLOG CI
on:
push:
branches: [hexo]
pull_request:
branches: [hexo]
env:
TZ: Asia/Shanghai
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- name: Checkout Codes
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Hexo Dependencies
run: |
npm install hexo-cli -g
npm install
npm ls --depth 0
- name: Generate Files
run: |
echo "generate files"
hexo clean && hexo douban && hexo generate
hexo config theme cactus && hexo config url https://imtzz.com/cactus && hexo config public_dir public/cactus && hexo config language en
hexo generate
- name: Git Repository Update
run: |
echo "git repo update"
cd ./public
ls -a
echo '-------------------'
head -n 10 index.html
echo '-------------------'
git init
git add .
git config --global user.name "Github Action"
git config --global user.email ${{secrets.EMAIL}}
git commit -m "Github Action Auto Builder at `date +"%Y-%m-%d %H:%M"`"
git push --force "https://${{secrets.GITHUBTOKEN}}@${GH_REF}" master:master
git push --force "https://${{secrets.CODING_TOKEN_NAME}}:${{secrets.CODINGTOKEN}}@${Coding}" master:master
env:
GH_REF: github.com/tzzs/tzzs.github.io.git
Coding: e.coding.net/imtzz/Pages.git
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Configure SSH
run: |
mkdir -p ~/.ssh
echo "${KEY}" > ~/.ssh/deploy.key
chmod 600 ~/.ssh/deploy.key
cat >> ~/.ssh/config <<END
Host server
HostName $IP
User $USERNAME
IdentityFile ~/.ssh/deploy.key
StrictHostKeyChecking no
END
env:
IP: ${{secrets.SERVER_IP}}
USERNAME: ${{secrets.SERVER_USERNAME}}
KEY: ${{secrets.SERVER_PRIVATE_KEY}}
- name: Checkout Codes
uses: actions/checkout@v2
- name: Deploy to Server
run: |
echo "Deploy to Server..."
ls
echo "[test pwd]"
ssh server "pwd"
echo "[exec dpeloy.sh]"
ssh server < deploy.sh > /dev/null 2>&1