github - Github actions 如何在两台服务器上配置两个运行器
问题描述
我有一个名为api
.
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 实例。似乎第二个实例或工作流根本不使用。如何根据分支指定运行器和实例?
解决方案
如果您只有两个使用默认设置的跑步者,您将无法区分两者。因此,这样的工作只需要两者中的任何一个。
标签可以标记一个特定的跑步者,然后您可以直接选择。请参阅标签上的 GitHub 自托管运行器文档
然后您可以像这样使用特定的跑步者
runs-on: [self-hosted, dev]
推荐阅读
- blockchain - 如何将开发密钥(Alice)从 `chain_specs.rs` 添加到本地密钥库?
- javascript - React Native - 尝试提取数据并存储在变量中
- gps - 尝试使用蓝图实现类似于 Pokemon 的真实现场位置
- sql - 为什么我的内部联接在以下数据库结构中无法正常工作
- vba - 如何使登录用户名和密码区分大小写
- c++ - 我正在用 C++ 编写更改输出程序。我没有得到正确的结果
- javascript - 这个事件发射器什么时候开始?
- azure-devops - 使用 Power Automate 更新 Azure DevOps 中的迭代路径
- visual-studio-code - VSCode 错误:在 127.0.0.1:6009 上启动检查器失败:地址已在使用中
- php - 将过滤器放入来自 firestore 的 livewire 搜索中