前言
最近由于一直在用的travis-ci出现了迷之bug,加上想尝试一下github action就决定尝试用github action替换travis-ci
选用action
github现有的action组件可以在这里查看. 如果想要自定义自己仓库的workflow,可以选用里面来进行组合.
不过hugo在github page的workflow,已经有人在这弄好了,
编写workflow
workflow定义是一个位于.github/workflows/的yaml文件.点开仓库的action按钮会出现引导界面

显示一些常用的workflow 但由于我们要用并不在这里面 点击右上角的skip就行.
模板文件
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
| name: github pages
on:
push:
branches:
# 你的hugo源码分支
- master
jobs:
build-deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
# 如果使用了git submodules
# with:
# submodules: true
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.59.1'
# extended: true
- name: Build
run: hugo --minify
- name: Deploy
uses: peaceiris/actions-gh-pages@v2.5.0
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY}}
# 你的github page分支
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public
|
设置secrets
之后需要设置secrets.secrets.ACTIONS_DEPLOY_KEY实际上是你的github Personal access tokens,申请后点击项目的setting,在secrets栏添加一个key名是PERSONAL_TOKEN的secrets即可
文章来源: https://blue-bird1.github.io/posts/github-action-hugo/
如有侵权请联系:admin#unsafe.sh