Skip to content

Commit

Permalink
完全使用actions进行pages部署
Browse files Browse the repository at this point in the history
  • Loading branch information
riba2534 committed Oct 27, 2024
1 parent da5c1ba commit 11040a4
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@ name: GitHub Pages Deploy
on:
push:
branches:
- main # 监听 main 分支的 push 事件
- 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@v2
uses: actions/checkout@v3
with:
submodules: true # 下载主题的子模块
submodules: true # 拉取主题子模块

- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
Expand All @@ -22,11 +27,15 @@ jobs:
extended: true # 使用 Hugo 扩展版

- name: Build site
run: hugo --minify # 使用 Hugo 生成静态站点,并最小化输出
run: hugo --minify # 生成静态站点,并最小化输出

- name: Upload artifact to Pages
uses: actions/upload-pages-artifact@v1
with:
path: ./public # Hugo 生成的静态文件目录

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
uses: actions/deploy-pages@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }} # GitHub 自动提供的令牌
publish_dir: ./public # Hugo 生成的静态文件目录
cname: 'blog.riba2534.cn' # 自定义域名
github_token: ${{ secrets.GITHUB_TOKEN }}
environment: github-pages

0 comments on commit 11040a4

Please sign in to comment.