-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (166 loc) · 8.02 KB
/
main.yml
File metadata and controls
167 lines (166 loc) · 8.02 KB
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
name: Auto build blog
on:
push:
branches:
- main
repository_dispatch:
workflow_dispatch:
jobs:
build-main:
name: Build Main
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- name: Setup Node.js
uses: actions/setup-node@main
with:
node-version: lts/*
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: 3.x
- name: Check out code
uses: actions/checkout@main
- name: Fetch Posts
run: |
git clone https://${{secrets.POST_CHECKOUT_TOKEN}}@github.com/Potat0000/Blog-Posts.git source/_posts
python3 build_script/gen_updatedtime.py
rm -rf source/_posts/.git*
- name: Install packages
run: |
npm install -g hexo-cli
npm install
- name: Get and Patch Lib Files
run: |
mv source/favicon/* source/
rm -rf source/favicon
curl https://cdn.jsdelivr.net/gh/PrismJS/prism-themes@master/themes/prism-material-light.min.css --create-dirs -o node_modules/prismjs/themes/prism-materiallight.css
curl https://cdn.jsdelivr.net/gh/PrismJS/prism-themes@master/themes/prism-material-oceanic.min.css --create-dirs -o node_modules/prismjs/themes/prism-materialoceanic.css
mv source/beian.ejs node_modules/hexo-theme-fluid/layout/_partials/footer/beian.ejs
- name: Build
run: |
hexo g
sed -i 's,IEJUMPIEJUMPIEJUMP,if(/*@cc_on!@*/false||(!!window.MSInputMethodContext\&\&!!document.documentMode))window.location.href="https://support.dmeng.net/upgrade-your-browser.html?referrer="+encodeURIComponent(window.location.href);,g' $(grep IEJUMPIEJUMPIEJUMP -rl ./public)
- name: Clean up
run: |
cd public
rm -rf xml
rm img/default.png img/fluid.png
- name: Minify
uses: docker://devatherock/minify-js:3.0.0
with:
directory: public
add_suffix: false
- name: Deploy to TencentCloud COS
env:
SECRET_ID: ${{ secrets.TENCENTCLOUD_SECRET_ID }}
SECRET_KEY: ${{ secrets.TENCENTCLOUD_SECRET_KEY }}
REGION: ap-shanghai
BUCKET: potat0-box-1307988268
run: |
pip install coscmd
coscmd config -a $SECRET_ID -s $SECRET_KEY -b $BUCKET -r $REGION
cd public
coscmd upload -rfs --delete ./ /
- name: Prepare URL List for Refresh and Prefetch
run: |
echo "https://www.potat0.cc/" > urls.txt
cd public
find . -type f -not -path '*/.*' -not -path './index.html' -not -path './posts/*' | sed "s|^./|https://www.potat0.cc/|" >> ../urls.txt
find . -type f -not -path '*/.*' -a -path './posts/*' -a \( -name '*.html' -o -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' -o -name '*.bmp' -o -name '*.gif' -o -name '*.svg' -o -name '*.webp' \) | sed "s|^./|https://www.potat0.cc/|" >> ../urls.txt
cd ..
echo "$(wc -l < urls.txt) URLs in total"
- name: Refresh and Prefetch TencentCloud EdgeOne
env:
TENCENTCLOUD_SECRET_ID: ${{ secrets.TENCENTCLOUD_SECRET_ID }}
TENCENTCLOUD_SECRET_KEY: ${{ secrets.TENCENTCLOUD_SECRET_KEY }}
TENCENTCLOUD_REGION: ap-shanghai
run: |
pip install tccli
tccli teo CreatePurgeTask --cli-unfold-argument --ZoneId zone-3d2iwq53tqx6 --Type purge_host --Targets 'www.potat0.cc'
cat urls.txt | xargs -I {} tccli teo CreatePrefetchTask --cli-unfold-argument --ZoneId zone-3d2iwq53tqx6 --Targets {}
build-cn:
name: Build CN
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- name: Setup Node.js
uses: actions/setup-node@main
with:
node-version: lts/*
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: 3.x
- name: Check out code
uses: actions/checkout@main
- name: Fetch Posts
run: |
git clone https://${{secrets.POST_CHECKOUT_TOKEN}}@github.com/Potat0000/Blog-Posts.git source/_posts
python3 build_script/gen_updatedtime.py
rm -rf source/_posts/.git*
- name: Install packages
run: |
npm install -g hexo-cli
npm install
- name: Get and Patch Lib Files
run: |
mv source/favicon/* source/
rm -rf source/favicon
curl https://cdn.jsdelivr.net/gh/PrismJS/prism-themes@master/themes/prism-material-light.min.css --create-dirs -o node_modules/prismjs/themes/prism-materiallight.css
curl https://cdn.jsdelivr.net/gh/PrismJS/prism-themes@master/themes/prism-material-oceanic.min.css --create-dirs -o node_modules/prismjs/themes/prism-materialoceanic.css
mv source/beian.ejs node_modules/hexo-theme-fluid/layout/_partials/footer/beian.ejs
- name: Patch for CN-Domain website
run: |
sed -i 's/www.potat0.cc/www.土豆.space/g' _config.yml
sed -i 's/www.potat0.cc/www.土豆.space/g' source/manifest.json
sed -i 's/www.potat0.cc/www.土豆.space/g' source/robots.txt
sed -i 's/icp_text: 浙ICP备2021017952号-1/icp_text: 浙ICP备2021017952号-2/g' _config.fluid.yml
sed -i 's/police_text: 浙公网安备33010602011812号/police_text: 浙公网安备33010602013468号/g' _config.fluid.yml
sed -i 's/police_code: 33010602011812/police_code: 33010602013468/g' _config.fluid.yml
sed -i 's/moeicp_code: 20221816/moeicp_code: 20241816/g' _config.fluid.yml
perl -0777 -np -i -e 's,(-{10}\n\n).*xn--udsw05j\.space.*(\n\n-{10}),\1这是本站的一个中文域名的实验性站点,你可以 [点击此处](https://www.potat0.cc/) 访问标准网站。\2,g' source/about/index.md
- name: Build
run: |
hexo g
sed -i 's,IEJUMPIEJUMPIEJUMP,if(/*@cc_on!@*/false||(!!window.MSInputMethodContext\&\&!!document.documentMode))window.location.href="https://support.dmeng.net/upgrade-your-browser.html?referrer="+encodeURIComponent(window.location.href);,g' $(grep IEJUMPIEJUMPIEJUMP -rl ./public)
- name: Clean up
run: |
cd public
rm -rf xml
rm img/default.png img/fluid.png
- name: Minify
uses: docker://devatherock/minify-js:3.0.0
with:
directory: public
add_suffix: false
- name: Deploy to Aliyun OSS
uses: fangbinwei/aliyun-oss-website-action@v1
with:
accessKeyId: ${{ secrets.ALIYUN_ACCESSKEY_ID }}
accessKeySecret: ${{ secrets.ALIYUN_ACCESSKEY_SECRET }}
bucket: potat0-box-cn
endpoint: oss-cn-hangzhou.aliyuncs.com
folder: public
incremental: true
skipSetting: true
- name: Prepare URL List for Refresh and Prefetch
run: |
echo "https://www.xn--udsw05j.space/" > urls.txt
echo "https://www.xn--udsw05j.space/" > url-dir.txt
cd public
find . -type f -not -path '*/.*' -not -path './index.html' -not -path './posts/*' | sed "s|^./|https://www.xn--udsw05j.space/|" >> ../urls.txt
find . -type f -not -path '*/.*' -a -path './posts/*' -a \( -name '*.html' -o -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' -o -name '*.bmp' -o -name '*.gif' -o -name '*.svg' -o -name '*.webp' \) | sed "s|^./|https://www.xn--udsw05j.space/|" >> ../urls.txt
cd ..
echo "$(wc -l < urls.txt) URLs in total"
- name: Refresh and Prefetch Aliyun CDN
run: |
pip install aliyun-python-sdk-core aliyun-python-sdk-cdn
python3 build_script/aliyun-cdn.py -i ${{secrets.ALIYUN_ACCESSKEY_ID}} -k ${{secrets.ALIYUN_ACCESSKEY_SECRET}} -r ./urls.txt -t clear -o File
python3 build_script/aliyun-cdn.py -i ${{secrets.ALIYUN_ACCESSKEY_ID}} -k ${{secrets.ALIYUN_ACCESSKEY_SECRET}} -r ./url-dir.txt -t clear -o Directory
sleep 3
python3 build_script/aliyun-cdn.py -i ${{secrets.ALIYUN_ACCESSKEY_ID}} -k ${{secrets.ALIYUN_ACCESSKEY_SECRET}} -r ./urls.txt -t push