update to local images #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: Deplo To Github Pages | |
on: | |
# 允许手动push触发 | |
push: | |
branches: | |
- main | |
# 允许外部仓库事件触发 | |
repository_dispatch: | |
types: | |
- deploy | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 检查分支 | |
uses: actions/checkout@master | |
- name: 安装node环境 | |
uses: actions/setup-node@master | |
with: | |
node-version: "16.x" | |
- name: 安装依赖 | |
run: | | |
export TZ='Asia/Shanghai' | |
npm install --prod | |
- name: 拉取语雀/Notion的文章 | |
env: | |
# Notion相关环境变量 | |
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} | |
NOTION_DATABASE_ID: ${{ secrets.NOTION_DATABASE_ID }} | |
run: | | |
# 对应package.json中的script.sync | |
npm run sync | |
- name: 配置Git用户名邮箱 | |
run: | | |
git config --global user.name "qxdo" | |
git config --global user.email "[email protected]" | |
- name: 提交拉取的文章到GitHub仓库 | |
run: | | |
echo `date +"%Y-%m-%d %H:%M:%S"` begin > time.txt | |
git add . | |
git commit -m "更新文档" -a | |
- name: 推送文章到仓库 | |
uses: ad-m/github-push-action@master | |
with: | |
# GITHUB_TOKEN为流水线内置变量,无需配置,可直接使用 | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: 生成静态文件 | |
run: | | |
# 对应package.json中的script.build | |
npm run build | |
- name: 部署到Github Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
# github_token和personal_token适用于推送到当前仓库 | |
# 也就是你的Github Pages仓库(xxxx/xxxx.github.io) | |
# 一般都不直接在Github Pages仓库开发,所以推荐使用deploy_key | |
# github_token: ${{ secrets.GITHUB_TOKEN }} | |
# personal_token: ${{ secrets.PERSONAL_TOKEN }} | |
# deploy_key可以推送到别的仓库, SSH_PRIVATE_KEY 为自己电脑的ssh私钥 | |
deploy_key: ${{ secrets.SSH_PRIVATE_KEY }} | |
# 具体目录以自己实际情况为准 | |
publish_dir: docs/.vitepress/dist | |
external_repository: qxdo/qxdo.github.io | |
publish_branch: gh-pages | |
commit_message: ${{ github.event.head_commit.message }} |