-
Notifications
You must be signed in to change notification settings - Fork 2
128 lines (113 loc) · 4.88 KB
/
auto-deploy.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# .github/workflows/auto-deploy.yml
name: auto deploy 🚀
on:
# 监听push操作
push:
branches:
- main # 这里只配置了main分支,所以只有推送main分支才会触发以下任务
pull_request:
# 这个选项可以使你手动在 Action tab 页面触发工作流
# workflow_dispatch:
permissions:
# 允许对仓库的内容进行写操作。包括创建、修改和删除文件、目录以及提交更改等
# 这里只配置了push,所以只有推送main分支才会触发以下任务
contents: write
# 允许管理 GitHub Pages 服务并对其进行写操作
pages: write
jobs:
# 任务ID
build-and-deploy:
# 运行环境
# runs-on: macos-latest
# runs-on: windows-latest
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# 步骤
steps:
# 官方action,将代码拉取到虚拟机
- name: Checkout
uses: actions/checkout@v4
# 建一个名为setup-node的步骤(安装指定版本的Node.js)
- name: setup-node
# 使用setup-node@v3这个action
uses: actions/setup-node@v4
# 指定某个action 可能需要输入的参数
with:
node-version: '18.12.1'
# 安装依赖
- name: Install dependencies
run: npm install
# 打包
- name: Build application 🔧
run: npm run build github
# 部署 https://github.com/JamesIves/github-pages-deploy-action
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
if: github.ref == 'refs/heads/main'
with:
token: ${{ secrets.MB_ADMIN_TOKEN }}
branch: gh-pages # default: gh-pages
folder: dist-github
clean: true # Automatically remove deleted files from the deploy branch
# commit-message: ${{ github.event.head_commit.message }} # default: `Deploying to gh-pages from @ 3238feb 🚀`
# commit-message: "deploy: ${{ github.sha }} (${{ github.event.head_commit.message }}) 🚀 "
sync-to-gitee:
# github 构建部署成功后触发
needs: build-and-deploy
runs-on: ubuntu-latest
steps:
# 官方action,将代码拉取到虚拟机
- name: Checkout
uses: actions/checkout@v4
# 建一个名为setup-node的步骤(安装指定版本的Node.js)
- name: setup-node
# 使用setup-node@v3这个action
uses: actions/setup-node@v4
# 指定某个action 可能需要输入的参数
with:
node-version: '18.12.1'
# 安装依赖
- name: Install dependencies
run: npm install
# 打包
- name: Build application
run: npm run build gitee
# 部署 https://github.com/JamesIves/github-pages-deploy-action
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
if: github.ref == 'refs/heads/main'
with:
token: ${{ secrets.MB_ADMIN_TOKEN }}
branch: gh-pages-gitee # default: gh-pages
folder: dist-gitee
clean: true # Automatically remove deleted files from the deploy branch
# commit-message: ${{ github.event.head_commit.message }} # default: `Deploying to gh-pages from @ 3238feb 🚀`
# commit-message: "deploy: ${{ github.sha }} (${{ github.event.head_commit.message }}) 🚀 "
## 同步代码
- name: Sync Code # 名字随便起
uses: Yikun/hub-mirror-action@master # 使用Yikun/hub-mirror-action
with:
src: github/syh-micro-build # 源端账户名(github)
dst: gitee/shanyi-hui # 目的端账户名(gitee)
dst_key: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} # SSH密钥对中的私钥
dst_token: ${{ secrets.GITEE_TOKEN }} # Gitee账户的私人令牌
src_account_type: org # 源端账户类型
dst_account_type: user # 目的端账户类型
clone_style: 'ssh' # 使用https方式进行clone,也可以使用ssh
debug: true # 启用后会显示所有执行命令
force_update: true # 启用后,强制同步,即强制覆盖目的端仓库
static_list: 'mb-admin' # 静态同步列表,在此填写需要同步的仓库名称,可填写多个
timeout: '600s' # git超时设置,超时后会自动重试git操作
- name: Build Pages
uses: yanglbme/gitee-pages-action@main
with:
# 注意替换为你的 Gitee 用户名
gitee-username: ShanYi-Hui
# 注意在 Settings->Secrets 配置 GITEE_PASSWORD
gitee-password: ${{ secrets.GITEE_PASSWORD }}
# 注意替换为你的 Gitee 仓库,仓库名严格区分大小写,请准确填写,否则会出错
gitee-repo: shanyi-hui/mb-admin
# 要部署的分支,默认是 master,若是其他分支,则需要指定(指定的分支必须存在)
branch: gh-pages-gitee
https: true