【发布时间】:2021-08-10 02:58:12
【问题描述】:
我有一个名为 api 的 GitHub 存储库。
api有两个分支DEV和QA
我已经为DEV 分支设置了一个工作流并且工作正常。
这是DEV 分支的工作流程
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [DEV]
pull_request:
branches: [DEV]
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [14.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
# - run: pm2 stop app.js
- run: pm2 start ecosystem.config.js --update-env
然后我创建了我的第二个 EC2 实例和第二个运行器以及另一个工作流文件
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: QA Build
on:
push:
branches: [ QA ]
pull_request:
branches: [ QA ]
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [14.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm i
- run: pm2 start ecosystem.config.js --update-env
但是,每当我将一些代码推送到 QA 分支时,我的第一个运行程序和第一个 EC-2 实例仍然运行。似乎第二个实例或工作流根本不使用。
如何根据分支指定runner和instance?
【问题讨论】:
标签: github github-actions cicd