This repository has been archived on 2025-06-28. You can view files and clone it, but cannot push or open issues or pull requests.
Files
vitepress-theme-blog-charle…/.github/workflows/deploy-pages.yml

76 lines
2.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Deploy Pages
on:
# 推送时执行
push:
branches: [main, master]
# pr时执行
pull_request:
branches: [main, master]
# 定时执行,字段含义:分钟 小时 日 月 星期
# 注意:
# 1.时间采用的是 UTC 时间
# 例如UTC00:00 ==GMT+080008:00
# 例如UTC17:30 ==GMT+080001:30
# 2.官方声明schedule 事件在 GitHub Actions 工作流运行期间负载过高时可能会延迟。 高负载时间包括每小时的开始时间。 为了降低延迟的可能性,建议将您的工作流程安排在不同时间运行。
# 例如:笔者之前设定的定时规则为 0 0 * * *实际GMT+0800执行时间通常在 9:10 ~ 10:00甚至会出现在 10:00 之后执行的情况
schedule:
- cron: 21 17 * * *
# 可手动执行
workflow_dispatch:
jobs:
# 任务1: 部署 GitHub Pages
deploy-github-pages:
runs-on: ubuntu-latest
steps:
# 1、检出源码
- name: Checkout
uses: actions/checkout@v3
# 2、安装 PNPM
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: latest
# 3、安装 Node 环境
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org
cache: pnpm
# 4、安装依赖
- name: Install dependencies
run: pnpm i --frozen-lockfile
# 5、打包
- name: Build
run: pnpm build
# 6、部署 GitHub Pages
- name: Deploy GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
BRANCH: pages
FOLDER: docs/.vitepress/dist
# 任务2: 部署 Gitee Pages
deploy-gitee-pages:
runs-on: ubuntu-latest
steps:
# 1、同步内容到 Gitee
- name: Sync to Gitee
uses: wearerequired/git-mirror-action@master #使用action库
env:
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} #Gitee私钥
with:
source-repo: git@github.com:Charles7c/charles7c.github.io.git #GitHub 源仓库地址
destination-repo: git@gitee.com:Charles7c/charles7c.git #Gitee 目标仓库地址
# 2、部署 Gitee Pages
- name: Deploy Gitee Pages
# 手动执行时只同步内容, 不进行部署
if: github.event_name != 'workflow_dispatch'
uses: yanglbme/gitee-pages-action@main
with:
gitee-username: ${{ secrets.GITEE_USERNAME }} #Gitee 用户名
gitee-password: ${{ secrets.GITEE_PASSWORD }} #Gitee 密码
gitee-repo: Charles7c/charles7c #Gitee 仓库
branch: pages #要部署的分支,默认是 master若是其他分支则需要指定指定的分支必须存在