完全使用actions进行pages部署 #7
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: GitHub Pages Deploy | ||
on: | ||
push: | ||
branches: | ||
- main # 当 main 分支有新提交时触发部署 | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read # 读取仓库内容 | ||
pages: write # 写入 GitHub Pages 部署内容 | ||
id-token: write # 用于身份验证的 ID 令牌 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true # 拉取主题子模块 | ||
- name: Setup Hugo | ||
uses: peaceiris/actions-hugo@v2 | ||
with: | ||
hugo-version: 'latest' | ||
extended: true # 使用 Hugo 扩展版 | ||
- name: Build site | ||
run: hugo --minify # 生成静态站点,并最小化输出 | ||
- name: Upload artifact to Pages | ||
uses: actions/upload-pages-artifact@v1 | ||
with: | ||
path: ./public # Hugo 生成的静态文件目录 | ||
- name: Deploy to GitHub Pages | ||
uses: actions/deploy-pages@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
environment: github-pages | ||