迫于从某厂离职,每个月白嫖的300CNY良心云额度不复存在,考虑到之前的博客维护都比较的古老,趁机也做一波升级。
在这次维护之前,博客的本体存放在我的NAS上,并通过FRP暴露出去外接一个良心云cdn用来分发,也顺便做了备案,这一套之前跑起来没啥问题,就是每次 generate 之后还需要手动 copy 产物到某个特定的文件夹,非常的不现代化。 由于整体的环境都在本地,所以其实可维护性很低。
更新的思路大概如下:
- 对博客项目进行梳理,清理掉不规范的配置
- 博客的本体部分由 github actions 生成并推送到 Azure Static Web App
- 对境内而言,还是走CDN分发,分发回源地址由之前的 FRP 暴露的地址改为 Azure Static Web App 生成的地址
- 境外部分,dnspod支持分线路解析,直接通过 Custom domain 功能分发即可
GitHub actions 写起来也是挺简单的,改了改模板就能直接用。 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
52name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
jobs:
build_and_deploy_job:
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 19
- uses: actions/checkout@v2
with:
submodules: true
- name: Install pandoc
run: sudo apt-get update -y && sudo apt-get install pandoc -y
- name: Install hexo-cli
run: npm install hexo-cli -g
- name: Npm install
run: npm install
- name: Hexo generate
run: hexo g
- name: Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GREEN_STONE_0480A0D00 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/public" # App source code path
api_location: "" # Api source code path - optional
output_location: "" # Built app content directory - optional
###### End of Repository/Build Configurations ######
# close_pull_request_job:
# if: github.event_name == 'pull_request' && github.event.action == 'closed'
# runs-on: ubuntu-latest
# name: Close Pull Request Job
# steps:
# - name: Close Pull Request
# id: closepullrequest
# uses: Azure/static-web-apps-deploy@v1
# with:
# azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GREEN_STONE_0480A0D00 }}
# action: "close"
这次迁移遗留几个问题待解决:
- 图库目前是在良心云 COS 上,需要迁走
- 境外的图片访问仍需要路由回国内
- 考虑到科学上网已经是基本技能,境内的加速是否存在必要?