init push #1
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: CI - build and test on gh-pages | |
# 在 push 时触发 | |
on: | |
push: | |
branches: | |
- '*' | |
- '!gh-pages' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Cache Hugo resources | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-hugo-resources | |
with: | |
path: resources | |
key: ${{ env.cache-name }} | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: "^1.19.1" # 设定 Go 的版本 | |
- run: go version | |
- name: Cache Go Modules # 当前的模板依赖于这样的更新方式 | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Setup Hugo ✨ # 使用最新版本的扩展版 Hugo 构建 | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: "latest" | |
extended: true | |
- name: Hugo Build 🛠️ | |
run: hugo --minify --gc | |
- name: Deploy to gh-pages 🚀 # gh-pages 用于测试目的,同时也是 staging 环境 | |
uses: JamesIves/github-pages-deploy-action@4.1.4 | |
with: | |
branch: gh-pages | |
folder: public | |
clean: true | |
single-commit: true |