Skip to content

迁移主站至腾讯云 EdgeOne Pages #374

迁移主站至腾讯云 EdgeOne Pages

迁移主站至腾讯云 EdgeOne Pages #374

Workflow file for this run

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 EdgeOne Pages
run: npx edgeone pages deploy ./public -n potat0-box -t ${{secrets.EDGEONE_API_TOKEN}}
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