Saul's blog Saul's blog
首页
后端
分布式
前端
更多
分类
标签
归档
友情链接
关于
GitHub (opens new window)

Saul.J.Wu

立身之本,不在高低。
首页
后端
分布式
前端
更多
分类
标签
归档
友情链接
关于
GitHub (opens new window)
  • 面试题

  • 博客搭建

    • Github Actions自动部署
    • 关于Github Actions发版姿势补充
      • 前言
      • 解决
      • 后话
      • 现在
  • 部署相关

  • 填坑

  • Python

  • 其他

  • 收藏夹

  • 友情链接
  • 更多
  • 博客搭建
SaulJWu
2021-11-13

关于Github Actions发版姿势补充

# 前言

由于以前的自动发版插件他更新了,使用master版本居然发不了。

后来仔细一看原来早就取消master分支(怪我太久没更新博客。。。),最新版本都去到4.1.5了。

发现网上作业也没得抄,毕竟关于我这个 Vdoing (opens new window)主题的发版姿势是有点不同(可能是我太菜)

作者也换发版姿势了,但是没作业抄。

于是我去研究官网的https://github.com/JamesIves/github-pages-deploy-action插件

发现官网guide里面的环境变量也完全不一样了。

# 解决

经过一些测试,自动触发成功了,只需要把BUILD_SCRIPT的抽离成一个步骤就可以了,姿势为:

name: CI

#on: [push]

# 在master分支发生push事件时触发。
on:
  push:
    branches:
      - master

jobs: # 工作流
  build: # 自定义名称
    runs-on: ubuntu-latest #运行在虚拟机环境ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x]

    steps: # 步骤
      - name: Checkout 🛎️
        uses: actions/checkout@v1 # 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions

      - name: Use Node.js ${{ matrix.node-version }} # 步骤2
        uses: actions/setup-node@v1 # 作用:安装nodejs
        with:
          node-version: ${{ matrix.node-version }} # 版本

      - name: run deploy.sh # 步骤3 (同时部署到github和coding)
        env: # 设置环境变量
          GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} # toKen私密变量
          # CODING_TOKEN: ${{ secrets.CODING_TOKEN }}
        run: npm install && npm run deploy

      - name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
        run: |
          npm install
          npm run build
          cd docs/.vuepress/dist
          cd -

      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@4.1.5 # 作用:将项目构建和部署到github。 https://github.com/JamesIves/github-pages-deploy-action
        with:
          branch: gh-pages # The branch the action should deploy to.
          folder: docs/.vuepress/dist # The folder the action should deploy.
        # env: # 设置环境变量
        #   ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # toKen私密变量
        #   BASE_BRANCH: master # 要部署的文件夹所在的分支.
        #   BRANCH: gh-pages # 部署到的分支
        #   FOLDER: docs/.vuepress/dist # 要部署的文件夹.
        # BUILD_SCRIPT: npm install && npm run build && cd docs/.vuepress/dist  && cd - # 部署前要执行的命令(记得cd进入某个目录后,后面要cd -退回开始的目录)
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

image-20211113124307797 (opens new window)

# 后话

1.现在这个插件支持源码仓库与gh-pages分开了,先看一段时间吧,以后再看看有没有必要分开吧。

2.我现在同步到gitee的ci是和github的ci是分开的,是要触发2次ci,现在找到一个作业https://blog.51cto.com/u_15273875/2917416,以后再看看把2个ci合并同一个吧。

# 现在

现在已经合并了,改为:

name: CI

# 在master分支发生push事件时触发。
on:
  push:
    branches:
      - master

jobs: # 工作流
  build: # 自定义名称
    runs-on: ubuntu-latest #运行在虚拟机环境ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x]

    steps: # 步骤
      - name: Checkout 🛎️
        uses: actions/checkout@v1 # 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions

      - name: Use Node.js ${{ matrix.node-version }} # 步骤2
        uses: actions/setup-node@v1 # 作用:安装nodejs
        with:
          node-version: ${{ matrix.node-version }} # 版本

      # - name: run deploy.sh # 步骤3 (同时部署到github和coding)
      #   env: # 设置环境变量
      #     GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} # toKen私密变量
      #     # CODING_TOKEN: ${{ secrets.CODING_TOKEN }}
      #   run: npm install && npm run deploy

      - name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
        run: |
          npm install
          npm run build
          cd docs/.vuepress/dist
          cd -

      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@4.1.5 # 作用:将项目构建和部署到github。 https://github.com/JamesIves/github-pages-deploy-action
        with:
          branch: gh-pages # The branch the action should deploy to.
          folder: docs/.vuepress/dist # The folder the action should deploy.

      - name: Sync to Gitee
        uses: wearerequired/git-mirror-action@master
        env:
          # 注意在 Settings->Secrets 配置 GITEE_RSA_PRIVATE_KEY
          SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
        with:
          # 注意替换为你的 GitHub 源仓库地址
          source-repo: git@github.com:SaulJWu/SaulJWu.github.io.git
          # 注意替换为你的 Gitee 目标仓库地址
          destination-repo: git@gitee.com:SaulJWu/SaulJWu.git

      - name: Build Gitee Pages
        uses: yanglbme/gitee-pages-action@master
        with:
          # 注意替换为你的 Gitee 用户名
          gitee-username: SaulJWu
          # 注意在 Settings->Secrets 配置 GITEE_PASSWORD
          gitee-password: ${{ secrets.GITEE_PASSWORD }}
          # 注意替换为你的 Gitee 仓库,仓库名严格区分大小写,请准确填写,否则会出错
          gitee-repo: SaulJWu/SaulJWu
          # 要部署的分支
          branch: gh-pages

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

原来的GiteeSync.yml可以删除了。

帮我改善此页面 (opens new window)
上次更新: 2021/11/13, 06:52:23
Github Actions自动部署
JenKins和GitLab

← Github Actions自动部署 JenKins和GitLab→

最近更新
01
zabbix学习笔记二
02-28
02
zabbix学习笔记一
02-10
03
Linux访问不了github
12-08
更多文章>
Theme by Vdoing | Copyright © 2020-2022 Saul.J.Wu | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式