forked from oddfar/notes
-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (48 loc) · 2.31 KB
/
Copy pathci.yml
File metadata and controls
56 lines (48 loc) · 2.31 KB
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
name: CI
#on: [push]
# 在master分支发生push事件时触发。
on:
push:
branches:
- master
jobs: # 工作流
build: # 自定义名称
runs-on: ubuntu-latest #运行在虚拟机环境ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps: # 步骤
- name: Checkout # 步骤1
# 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions
uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }} # 步骤2
uses: actions/setup-node@v1 # 作用:安装nodejs
with:
node-version: ${{ matrix.node-version }} # 版本
#-------------------------------------------------------------------
- name: Configure Private Key #★★★★★★ 步骤3:设置ssh ★★★★★★
env:
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} # gitee的ssh
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "StrictHostKeyChecking no" >> ~/.ssh/config
- name: Push Gitee Mirror #★★★★★★ 步骤4:推送到gitee★★★★★★
env:
SOURCE_REPO: 'https://github.com/oddfar/notes.git' #github 仓库地址
run: |
git clone --mirror "$SOURCE_REPO" && cd `basename "$SOURCE_REPO"`
git remote set-url --push origin "$DESTINATION_REPO"
git fetch -p origin
git for-each-ref --format 'delete %(refname)' refs/pull | git update-ref --stdin
git push --mirror
#-------------------------------------------------------------------
- name: run deploy.sh # 步骤5:执行脚本deploy.sh
env: # 设置环境变量,未设置则不运行
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} # toKen私密变量
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} # gitee的ssh
run: npm install && npm run deploy
## ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
## 注意:不需要同步到gitee镜像,则把步骤3和4删掉