|
| 1 | +# name: CI |
| 2 | + |
| 3 | +# #on: [push] |
| 4 | + |
| 5 | +# # 在master分支发生push事件时触发。 |
| 6 | +# on: |
| 7 | +# push: |
| 8 | +# branches: |
| 9 | +# - master |
| 10 | + |
| 11 | +# env: # 设置环境变量 |
| 12 | +# TZ: Asia/Shanghai # 时区(设置时区可使页面中的`最近更新时间`使用该时区时间) |
| 13 | + |
| 14 | +# jobs: |
| 15 | +# build: # 自定义名称 |
| 16 | +# runs-on: ubuntu-latest # 运行在虚拟机环境ubuntu-latest |
| 17 | + |
| 18 | +# strategy: |
| 19 | +# matrix: |
| 20 | +# node-version: [18.x] |
| 21 | + |
| 22 | +# steps: |
| 23 | +# - name: Checkout # 步骤1 |
| 24 | +# uses: actions/checkout@v1 # 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions |
| 25 | +# - name: Use Node.js ${{ matrix.node-version }} # 步骤2 |
| 26 | +# uses: actions/setup-node@v3 # 作用:安装nodejs |
| 27 | +# with: |
| 28 | +# node-version: ${{ matrix.node-version }} # 版本 |
| 29 | +# - name: Build-and-deploy # 步骤3 |
| 30 | +# run: | |
| 31 | +# remote_addr=`git remote get-url --push origin` |
| 32 | +# commit_info=`git describe --all --always --long` |
| 33 | +# user_name=`git log -1 --pretty=format:'%an'` |
| 34 | +# user_email=`git log -1 --pretty=format:'%ae'` |
| 35 | +# deploy_branch=gh-pages |
| 36 | +# yarn |
| 37 | +# yarn build |
| 38 | +# cd docs/.vuepress/dist |
| 39 | +# git config --global init.defaultBranch $deploy_branch |
| 40 | +# git init |
| 41 | +# git config user.name ${user_name} |
| 42 | +# git config user.email ${user_email} |
| 43 | +# git add -A |
| 44 | +# git commit -m "auto deploy, $commit_info" |
| 45 | +# remote_addr=`echo $remote_addr | awk -F'://' '{print $2}'` |
| 46 | +# remote_addr=https://${user_name}:${{secrets.GITHUB_TOKEN}}@${remote_addr} |
| 47 | +# git remote add origin ${remote_addr} |
| 48 | +# git push origin HEAD:$deploy_branch --force # 推送到github $deploy_branch分支 |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
1 | 53 | name: CI |
2 | 54 |
|
3 | 55 | #on: [push] |
4 | 56 |
|
5 | | -# 在master分支发生push事件时触发。 |
6 | | -on: |
| 57 | +# 在 master 分支发生 push 事件时触发。 |
| 58 | +on: |
7 | 59 | push: |
8 | 60 | branches: |
9 | 61 | - master |
10 | | - |
| 62 | + |
11 | 63 | env: # 设置环境变量 |
12 | | - TZ: Asia/Shanghai # 时区(设置时区可使页面中的`最近更新时间`使用该时区时间) |
| 64 | + TZ: Asia/Shanghai # 时区(设置时区可使页面中的 最近更新时间 使用时区时间) |
13 | 65 |
|
14 | | -jobs: |
| 66 | +jobs: # 工作流 |
15 | 67 | build: # 自定义名称 |
16 | | - runs-on: ubuntu-latest # 运行在虚拟机环境ubuntu-latest |
| 68 | + runs-on: ubuntu-latest # 必填,运行在虚拟机环境 ubuntu-latest |
17 | 69 |
|
18 | 70 | strategy: |
19 | 71 | matrix: |
20 | | - node-version: [18.x] |
| 72 | + node-version: [14.x] |
21 | 73 |
|
22 | | - steps: |
23 | | - - name: Checkout # 步骤1 |
24 | | - uses: actions/checkout@v1 # 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions |
| 74 | + steps: # 步骤1 |
| 75 | + - name: Checkout # 步骤1,拉取代码 |
| 76 | + # 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions |
| 77 | + uses: actions/checkout@v1 |
| 78 | + |
25 | 79 | - name: Use Node.js ${{ matrix.node-version }} # 步骤2 |
26 | | - uses: actions/setup-node@v3 # 作用:安装nodejs |
| 80 | + uses: actions/setup-node@v1 # 作用:安装nodejs |
27 | 81 | with: |
28 | 82 | node-version: ${{ matrix.node-version }} # 版本 |
29 | | - - name: Build-and-deploy # 步骤3 |
30 | | - run: | |
31 | | - remote_addr=`git remote get-url --push origin` |
32 | | - commit_info=`git describe --all --always --long` |
33 | | - user_name=`git log -1 --pretty=format:'%an'` |
34 | | - user_email=`git log -1 --pretty=format:'%ae'` |
35 | | - deploy_branch=gh-pages |
36 | | - yarn |
37 | | - yarn build |
38 | | - cd docs/.vuepress/dist |
39 | | - git config --global init.defaultBranch $deploy_branch |
40 | | - git init |
41 | | - git config user.name ${user_name} |
42 | | - git config user.email ${user_email} |
43 | | - git add -A |
44 | | - git commit -m "auto deploy, $commit_info" |
45 | | - remote_addr=`echo $remote_addr | awk -F'://' '{print $2}'` |
46 | | - remote_addr=https://${user_name}:${{secrets.GITHUB_TOKEN}}@${remote_addr} |
47 | | - git remote add origin ${remote_addr} |
48 | | - git push origin HEAD:$deploy_branch --force # 推送到github $deploy_branch分支 |
| 83 | + |
| 84 | + - name: run deploy.sh # 步骤3:执行脚本 deploy.sh |
| 85 | + env: # 设置环境变量,未设置则不运行 |
| 86 | + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} # token |
| 87 | + SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} # 私钥 |
| 88 | + run: npm install && npm run deploy # 执行 deploy.sh 脚本,位于项目根目录 |
| 89 | + |
| 90 | + # - name: Push Matser To Gitee # 步骤4:GitHub 内容同步到 Gitee,同步仓库是 master |
| 91 | + # uses: wearerequired/git-mirror-action@master |
| 92 | + # env: |
| 93 | + # SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} |
| 94 | + # with: # 从源到目的地 |
| 95 | + # source-repo: 'git@github.com:Kele-Bingtang/notes-blog.git' #Github 仓库地址 |
| 96 | + # destination-repo: 'git@gitee.com:kele-bingtang/notes-blog.git' #Gitee 仓库地址 |
| 97 | + |
| 98 | + - name: Build Gitee Pages # 步骤5:自动部署到 Gitee Pages |
| 99 | + uses: yanglbme/gitee-pages-action@master |
| 100 | + with: |
| 101 | + # 注意替换为你的 Gitee 用户名 |
| 102 | + gitee-username: jywangyou |
| 103 | + # 注意在 Settings -> Secrets 配置 GITEE_PASSWORD |
| 104 | + gitee-password: ${{ secrets.GITEE_PASSWORD }} |
| 105 | + # 注意替换为你的 Gitee 仓库,仓库名严格区分大小写,请准确填写,否则会出错 |
| 106 | + gitee-repo: jywangyou/notes-blog |
| 107 | + # 要部署的分支,默认是 master,若是其他分支,则需要指定(指定的分支必须存在) |
| 108 | + branch: gh-pages |
0 commit comments