Update blog. #48
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: Deploy GitHub Pages | |
# 触发条件:在 push 到 master 分支后 | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: # 下列文件的变更不触发部署,可以自行添加 | |
- README.md | |
- LICENSE | |
# 任务 | |
jobs: | |
build-and-deploy: | |
# 服务器环境:最新版 Ubuntu | |
runs-on: ubuntu-latest | |
steps: | |
# 拉取代码 | |
- name: 📦 Checkout | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
# 0 indicates all history for all branches and tags. | |
# 修复 Github Actions 部署时导致文章的更新时间错误 | |
fetch-depth: 0 | |
# 如果仓库有 submodule,在这里更新,没有则删掉此步骤 | |
- name: 📦 Update Submodule | |
run: | | |
git submodule init | |
git submodule update --remote | |
# 修复 Github Actions 部署时导致文章的更新时间错误 | |
# https://aizhiqian.github.io/posts/e4c1b222/ | |
- name: Restore file modification time | |
run: find source -name '*.md' | while read file; do touch -d "$(git log -1 --format="@%ct" "$file")" "$file"; done | |
# 生成静态文件 | |
- name: 🔧 Install and Build | |
run: | | |
npm install hexo-cli -g | |
npm install | |
hexo clean | |
hexo generate | |
# 如果采用 yarn 进行包管理,则使用下面的代码 | |
# yarn | |
# yarn build | |
# 部署到 GitHub Pages | |
- name: 🚀 Deploy | |
uses: JamesIves/[email protected] | |
with: | |
# GitHub 的 Personal access tokens | |
token: ${{secrets.BLOG_DEPLOY}} | |
# 要部署到的分支 | |
branch: gh-pages | |
# 上一步生成的静态文件的地址 | |
folder: public |