-
Notifications
You must be signed in to change notification settings - Fork 2
220 lines (192 loc) · 7.29 KB
/
deployHexo.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: Blog markdown to hexo
on:
push:
branches:
- master
- website_Static
env:
GIT_USER: LetMeFly666
GIT_EMAIL: [email protected]
jobs:
build:
name: Build on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
node_version: [18.x]
steps:
# - name: Using cache
# uses: actions/cache@v3
# with:
# path: ~/.deploy_git
# key: deployGit
# restore-keys: deployGit
# - name: Check if cached
# run: |
# tree .. -d -a
- name: Checkout this repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
# - name: Install Python
# uses: actions/setup-python@v1
# with:
# python-version: 3.7
# - name: Install requirements
# run: |
# pip install requests
# - name: Use python to debug
# env:
# GITHUBLEETCODEDEPLOYKEY: ${{ secrets.GITHUBLEETCODEDEPLOYKEY }}
# FORPYTHONDEBUG: ${{ secrets.FORPYTHONDEBUG }}
# run: |
# python debug.py
- name: Config environment
env:
GITHUBLEETCODEDEPLOYKEY: ${{ secrets.GITHUBLEETCODEDEPLOYKEY }}
run: |
sudo timedatectl set-timezone "Asia/Shanghai"
mkdir -p ~/.ssh/
echo "${{ secrets.GITHUBLEETCODEDEPLOYKEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
git config --global user.name $GIT_USER
git config --global user.email $GIT_EMAIL
- name: Install hexo and init
run: |
npm install -g hexo-cli --save
hexo init ../hexoWorkspace
rm -f ../hexoWorkspace/source/_posts/hello-world.md # 不再显示Hello World这篇文章(每次都显示在首页)
sed -i 's/"<em>" + text + "<\/em>"/"_" + text + "_"/g' ../hexoWorkspace/node_modules/marked/lib/*
# cat ../hexoWorkspace/node_modules/marked/lib/*
# 上次commit记录
MESSAGE=$(git log -1 --format="%s")
HASH=$(git log -1 --format="%H")
# ENCODED_MESSAGE=$(printf "%s\n\n%s" "$MESSAGE" "$HASH" | base64)
# echo "ENCODED_MESSAGE=$ENCODED_MESSAGE" >> $GITHUB_ENV
# echo "$ENCODED_MESSAGE"
echo "$MESSAGE"
echo "$HASH"
echo "MESSAGE=$MESSAGE" >> $GITHUB_ENV
echo "HASH=$HASH" >> $GITHUB_ENV
- name: Copy config files from branch website_Static
run: |
cp -r Solutions ../Articles
echo --- > ../Articles/README.md
echo title: README >> ../Articles/README.md
echo date: 9999-12-31 14:53:21 >> ../Articles/README.md
echo tags: README >> ../Articles/README.md
echo top: true >> ../Articles/README.md
echo --- >> ../Articles/README.md
cat README.md >> ../Articles/README.md
git checkout website_Static
cp -r ToCopy ../staticFiles
# rm -rf ../staticFiles/source/_posts # 删除了 branch website_Static 的 ToCopy/source/_posts
mv ../Articles ../staticFiles/source/_posts
# mv -f ../staticFiles/* ../hexoWorkspace
rsync -a ../staticFiles/* ../hexoWorkspace
# echo tree ../hexoWorkspace/source/_posts
# sub theme: 明日方舟arknights
cp -r ../hexoWorkspace ../hexoWorkspace_arknights
- name: Install dependencies
run: |
cd ../hexoWorkspace
# npm install hexo-deployer-git --save
npm install lodash # 主题fluid需要使用
npm install css # 主题fluid需要使用
# npm uninstall hexo-renderer-marked --save
# sudo apt-get install pandoc
# npm install hexo-renderer-pandoc --save
cd ../LeetCode
cd ../hexoWorkspace_arknights
npm install lodash # 主题arknights需要使用
npm install css # 主题arknights需要使用
npm install hexo-generator-sitemap --save
cd ../LeetCode
- name: Generate hexo fluid
run: |
cd ../hexoWorkspace
echo hexo g:
hexo g
# echo hexo d:
# hexo d
cd ../LeetCode
- name: Generate hexo arknights
run: |
cd ../hexoWorkspace_arknights
sed -i 's/theme: fluid/theme: arknights/g' _config.yml
sed -i 's|url: https://[^/]*/|&theme/arknights/|' _config.yml
echo 'npm install hexo-renderer-pug --save'
npm install hexo-renderer-pug --save
echo 'hexo g'
hexo g
echo 'generated'
mkdir ../hexoWorkspace/public/theme/
mv public ../hexoWorkspace/public/theme/arknights
cd ../LeetCode
- name: Modify sitemap
run: |
echo "https://blog.letmefly.xyz/theme/arknights/sitemap.txt" > ../hexoWorkspace/public/sitemap.txt
sed 's/theme\/arknights\///g' ../hexoWorkspace/public/theme/arknights/sitemap.txt >> ../hexoWorkspace/public/sitemap.txt
cat ../hexoWorkspace/public/theme/arknights/sitemap.txt >> ../hexoWorkspace/public/sitemap.txt
- name: Push to github
run: |
git checkout website
ls -la
cp -r .git ../hexoWorkspace/public
cd ../hexoWorkspace/public
# DECODED_MESSAGE=$(echo "$ENCODED_MESSAGE" | base64 --decode)
# echo "$DECODED_MESSAGE"
TOCOMMIT=$(printf "%s\n\n%s" "$MESSAGE" "$HASH")
echo "$TOCOMMIT"
git add .
# git commit --allow-empty -m "$DECODED_MESSAGE"
git commit --allow-empty -m "$TOCOMMIT"
git push
cd ../../LeetCode
# - name: Move cache dir to other place
# run: |
# mv ../hexoWorkspace/.deploy_git ..
# tree .. -d -a
# - name: Using cache
# uses: actions/cache@v3
# with:
# path: ~/.deploy_git
# key: deployGit
# restore-keys: deployGit
# - name: Try to keep logs
# run: |
# echo tree -d -a ..
# tree -d -a ..
# mv .deploy_git/.git .deploy_git/git
# rsync -a .deploy_git/* ../LeetCode/.deploy_git
# echo git config --list
# git config --list
# echo git remote -v
# git remote -v
# git add .
# git commit -m "backup .deploy_git"
# git push origin website_Static
# echo cat .git/config
# cat .git/config
# echo ssh -T [email protected]
# ssh -T [email protected]
# - name: Push to branch website_Static
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.WORKFLOWTOKEN }}
# # branch: ${{ github.ref }}
# # branch: website_Static
# branch: refs/heads/website_Static
# - name: Push to branch website_Static
# uses: EndBug/add-and-commit@v9
# with:
# author_name: LetMeFly
# author_email: [email protected]
# message: "backup .deploy_git"
# add: "."