chore: sync upstream commit 5c626cb to fix warnings #37
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: build-on-Github-Pages | |
# 在 master 分支更新时触发构建 | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-24.04 | |
permissions: # actions/deploy-pages@v4 需要 | |
pages: write | |
id-token: write | |
env: | |
TZ: Asia/Shanghai | |
SOURCE_REPO: "he-sb/tech" # 博客源码仓库 | |
steps: | |
# 配置 git,避免一些莫名其妙的错误 | |
- name: Git Configuration | |
run: | | |
git config --global core.quotePath false | |
git config --global core.autocrlf false | |
git config --global core.safecrlf true | |
git config --global core.ignorecase false | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
# 拉取源码 | |
- name: Clone Repository | |
run: | |
git clone --branch=master --quiet https://github.com/$SOURCE_REPO site | |
# 安装 hugo | |
- name: Setup Hugo | |
env: | |
HUGO_VERSION: 0.131.0 # hugo 版本号 | |
run: | | |
wget -q -O hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-amd64.deb && \ | |
sudo dpkg -i hugo.deb && \ | |
hugo version | |
# 构建 | |
- name: Build | |
env: | |
HUGO_ENVIRONMENT: production | |
HUGO_ENV: production | |
run: | |
cd site && hugo --gc --minify --cleanDestinationDir | |
# 上传构建结果 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: site/public/ | |
name: 'github-pages' | |
# 部署至 GitHub Pages | |
- name: Deploy to GitHub Pages | |
id: deployment | |
env: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
uses: actions/deploy-pages@v4 |