Skip to content

github pages

github pages #115

Workflow file for this run

name: github pages # 名字自取
on:
workflow_dispatch: {}
schedule:
- cron: "0 0 1,15 * *"
jobs:
deploy: # 任务名自取
runs-on: ubuntu-20.04 # 在什么环境运行任务
steps:
# 解决 https://github.com/peaceiris/actions-hugo/issues/496 问题,文件无法使用
- name: disable quotePath
run: git config --global core.quotePath false
- uses: actions/checkout@v3 # 引用 actions/checkout 这个 action,与所在的 github 仓库同名
with:
submodules: true # Fetch Hugo themes (true OR recursive) 获取submodule主题
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Setup Hugo # 步骤名自取
uses: peaceiris/actions-hugo@v2 # hugo 官方提供的 action,用于在任务环境中获取 hugo
with:
# hugo-version: "latest" # 获取最新版本的 hugo
hugo-version: "0.122.0" # 获取指定版本的 hugo
extended: true
- name: Build
run: |
npm install -D autoprefixer
npm install -D postcss-cli
npm install -D postcss
hugo --minify
- name: Deploy
uses: peaceiris/actions-gh-pages@v3 # 一个自动发布 github pages 的 action
with:
# github_token: ${{ secrets.GITHUB_TOKEN }} 该项适用于发布到源码相同 repo 的情况,不能用于发布到其他 repo
external_repository: DesistDaydream/desistdaydream.github.io # 发布到哪个 repo
personal_token: ${{ secrets.ACTION_ACCESS_TOKEN }} # 发布到其他 repo 需要提供上面生成的 personal access token
publish_dir: ./public # 注意这里指的是要发布哪个文件夹的内容,而不是指发布到目的仓库的什么位置,因为 hugo 默认生成静态网页到 public 文件夹,所以这里发布 public 文件夹里的内容
publish_branch: main # 发布到哪个 branch