博客通过GitHub Actions自动部署-hugo

有Hexo的经验在,还是比较简单的。

现在是hugo了,更新了一下workflow。

 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
name: Build blog
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    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 }}

    - name: cd blog
      run: cd blog

    - name: Install Hugo
      uses: peaceiris/actions-hugo@v2
      with:
        hugo-version: 'latest'
        extended: true

    - name: Build blog
      run: hugo --gc --verbose --minify
      
    - name: Install coscmd
      run: sudo pip install coscmd

    - name: Configure coscmd
      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
      run: coscmd upload -rs -f ./public/ /

不懂的话可以对照我 Hexo那篇 看。

使用 Hugo 构建
主题 StackJimmy 设计