60 lines
1.8 KiB
YAML
60 lines
1.8 KiB
YAML
name: Deploy Pages
|
||
|
||
on:
|
||
# 推送时执行
|
||
push:
|
||
branches: [main, master]
|
||
# pr时执行
|
||
pull_request:
|
||
branches: [main, master]
|
||
# 定时执行 00:01
|
||
schedule:
|
||
- cron: 1 0 * * *
|
||
# 可手动执行
|
||
workflow_dispatch:
|
||
|
||
jobs:
|
||
# 任务1: 部署 GitHub Pages
|
||
deploy-github-pages:
|
||
runs-on: ubuntu-latest
|
||
|
||
steps:
|
||
# 1、检出源码
|
||
- name: Checkout
|
||
uses: actions/checkout@v3
|
||
|
||
# 2、安装模块并打包
|
||
- name: Install and Build
|
||
run: |
|
||
yarn install
|
||
yarn build
|
||
|
||
# 3、部署 GitHub Pages
|
||
- name: Deploy GitHub Pages
|
||
uses: JamesIves/github-pages-deploy-action@v4
|
||
with:
|
||
BRANCH: pages
|
||
FOLDER: repos/.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,若是其他分支,则需要指定(指定的分支必须存在) |