从网上各色不一的教程中翻了很多车。还是看官方文档手搓比较好。
workflows 文件:
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
| name: Build blog
on: # 触发Actions的动作
push:
branches: [ master ] # 根据你的分支来填
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest # 使用的Linux
steps:
- uses: actions/checkout@v3
- name: Clone source files
uses: GuillaumeFalourd/clone-github-repo-action@v2
with:
owner: 'akatsukiro'
repository: 'blog'
access-token: ${{ secrets.PAT }} # 自己添加Personal Access Token
- name: cd blog
run: cd blog
- name: Install Node.js # Node.js v14
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Install Hexo
run: npm install hexo-cli -g
- name: install dependencies
run: npm install
- name: Build blog
run: hexo d -g
- name: Install coscmd # 上传到腾讯云COS需要的APP
run: sudo pip install coscmd
- name: Configure coscmd # 上传到COS需要的一些信息
env:
SECRET_ID: ${{ secrets.SecretId }}
SECRET_KEY: ${{ secrets.SecretKey }}
BUCKET: ${{ secrets.BucketId }}
REGION: ${{ secrets.Region }}
run: coscmd config -a $SECRET_ID -s $SECRET_KEY -b $BUCKET -r $REGION
- name: Upload # 上传build好的博客文件
run: coscmd upload -rs -f ./public/ /
|
这个workflow是我自己手搓的,可能有更简洁的实现方法,但我这个的确能跑,希望能给到你一个参考。