-
Notifications
You must be signed in to change notification settings - Fork 8
66 lines (58 loc) · 2.16 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Deploy GitHub Pages And Sync to Gitee
# 触发条件:在 push 到 main 分支后
on:
push:
branches:
- main
paths-ignore: # 下列文件的变更不触发部署
- LICENSE
# 任务
jobs:
build-and-deploy:
runs-on: ubuntu-latest # 部署运行环境搭建
steps:
- name: Checkout 🛎️
uses: actions/checkout@main
- name: Set USERNAME and REPO_NAME
run: |
echo "USERNAME=${{ github.actor }}" >> $GITHUB_ENV
echo "REPO_NAME=${{ github.repository }}" >> $GITHUB_ENV
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: latest
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest
run_install: true
- name: Build 🔧
run: |
pnpm run build
- name: 📲 Push To GitHub Pages
uses: ftnext/[email protected]
with:
build_dir: dist
github_token: ${{ secrets.DEPLOY_TOKEN }}
- name: Sync to Gitee
uses: wearerequired/git-mirror-action@master
env:
# 注意在 Settings->Secrets 配置 GITEE_RSA_PRIVATE_KEY(复制本机生成的 ~/.ssh/gitee )
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
with:
# GitHub 源仓库地址
source-repo: [email protected]:${{ env.REPO_NAME }}.git
# Gitee 目标仓库地址
destination-repo: [email protected]:${{ env.REPO_NAME }}.git
# 首次必须手动 Gitee 部署,否则会出错
- name: Build Gitee Pages
uses: yanglbme/gitee-pages-action@main
with:
# Gitee 用户名
gitee-username: ${{ env.USERNAME }}
# 在 Settings->Secrets 配置 GITEE_PSWD
gitee-password: ${{ secrets.GITEE_PSWD }}
# Gitee 仓库,仓库名严格区分大小写,请准确填写,否则会出错
gitee-repo: ${{ env.REPO_NAME }}
# 要部署的分支,默认是 master,若是其他分支,则需要指定(指定的分支必须存在)
branch: gh-pages