-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat: 使用来自hextra-starter-template的workflow脚本
1 parent
4088d43
commit 5d04c43
Showing
1 changed file
with
32 additions
and
34 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,76 @@ | ||
# 用于构建和部署Hugo网站到GitHub Pages的示例工作流程 | ||
name: 发布Hugo网站到Pages | ||
# Sample workflow for building and deploying a Hugo site to GitHub Pages | ||
name: Deploy Hugo site to Pages | ||
|
||
on: | ||
# 在目标为默认分支的推送上运行 | ||
# Runs on pushes targeting the default branch | ||
push: | ||
branches: | ||
- main | ||
branches: ["main"] | ||
|
||
# 允许您手动从“Actions”标签运行此工作流程 | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# 设置GITHUB_TOKEN的权限,以允许部署到GitHub Pages | ||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
# 仅允许一个并发部署,跳过在进行中的运行与最新排队的运行之间排队的运行。 | ||
# 但是,请不要取消进行中的运行,因为我们希望这些生产部署能够完成。 | ||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | ||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
# 默认使用bash | ||
# Default to bash | ||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
# 构建作业 | ||
# Build job | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
HUGO_VERSION: 0.125.2 | ||
HUGO_VERSION: 0.138.0 | ||
steps: | ||
- name: 安装Hugo CLI | ||
run: | | ||
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ | ||
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb | ||
- name: 安装Dart Sass | ||
run: sudo snap install dart-sass | ||
- name: 检出 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # fetch all history for .GitInfo and .Lastmod | ||
submodules: recursive | ||
fetch-depth: 0 | ||
- name: 设置Pages | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.23' | ||
- name: Setup Pages | ||
id: pages | ||
uses: actions/configure-pages@v3 | ||
- name: 安装Node.js依赖 | ||
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" | ||
- name: 使用Hugo构建 | ||
uses: actions/configure-pages@v4 | ||
- name: Setup Hugo | ||
run: | | ||
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ | ||
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb | ||
- name: Build with Hugo | ||
env: | ||
# 为了与Hugo模块的最大向后兼容性 | ||
# For maximum backward compatibility with Hugo modules | ||
HUGO_ENVIRONMENT: production | ||
HUGO_ENV: production | ||
run: | | ||
hugo \ | ||
--gc \ | ||
--minify \ | ||
--baseURL "${{ steps.pages.outputs.base_url }}/" | ||
- name: 上传构建产物 | ||
uses: actions/upload-pages-artifact@v2 | ||
--gc --minify \ | ||
--baseURL "${{ steps.pages.outputs.base_url }}/" | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: ./public | ||
|
||
# 部署作业 | ||
# Deployment job | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: 部署到GitHub Pages | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v2 | ||
uses: actions/deploy-pages@v4 |