升级主题版本 #353
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto build blog | |
on: | |
push: | |
branches: | |
- main | |
repository_dispatch: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
deployments: write | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- main | |
- cn | |
steps: | |
- name: Setup Node.js | |
uses: actions/setup-node@main | |
with: | |
node-version: 16.x | |
- 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: | | |
echo "MOEICP=20221816" >> $GITHUB_ENV | |
echo "OSS_BUCTET=potat0-box" >> $GITHUB_ENV | |
echo "REFRESH_URL=xn--udsw05j.space" >> $GITHUB_ENV | |
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 | |
if: ${{ matrix.platform == 'cn' }} | |
run: | | |
echo "MOEICP=20241816" >> $GITHUB_ENV | |
echo "OSS_BUCTET=potat0-box-cn" >> $GITHUB_ENV | |
echo "REFRESH_URL=potat0.cc" >> $GITHUB_ENV | |
sed -i 's/potat0.cc/土豆.space/g' _config.yml | |
sed -i 's/potat0.cc/土豆.space/g' source/manifest.json | |
sed -i 's/potat0.cc/土豆.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).*土豆\.space.*(\n\n-{10}),\1这是本站的一个中文域名的实验性站点,你可以在 [https://potat0.cc](https://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: ${{ env.OSS_BUCTET }} | |
endpoint: oss-cn-hangzhou.aliyuncs.com | |
folder: public | |
incremental: true | |
skipSetting: true | |
- name: Refresh Aliyun CDN | |
uses: visionwx/ali-cdn-refresh@v0.1.1 | |
with: | |
accessKeyId: ${{ secrets.ALIYUN_ACCESSKEY_ID }} | |
accessKeySecret: ${{ secrets.ALIYUN_ACCESSKEY_SECRET }} | |
type: Directory | |
path: https://${{ env.REFRESH_URL }}/ |