我想学习如何使用带标签的自托管github运行器。我在服务器上安装了一个自托管的github runner,并为它分配了标签prj1。然后我创建了一个github项目,并包含了这个.github/workflows/deploy.yml文件。
name: Environment
on:
push:
branches:
- master
jobs:
p1:
runs-on: self-hosted
steps:
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event." >> deploy-log.txt当我推送到master分支时,我的自托管github运行器显示成功。到目前为止,这是完美的。
然后,我更改了我的.github/workflows/deploy.yml,使其包含如下标签:
name: Environment
on:
push:
types: [prj1]
branches:
- master
jobs:
p1:
runs-on: self-hosted
steps:
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event." >> deploy-log.txt然后我推给师父。但github runner没有显示出任何检测到任何东西的迹象。github网站actions显示“此检查已跳过”。所以我试了一下:
name: Environment
on:
push:
branches:
- master
jobs:
p1:
if: ${{ github.event.label.name == 'prj1' }}
runs-on: self-hosted
steps:
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event." >> deploy-log.txt同样,当我向master推送更改时,git集线器运行器没有显示任何检测到任何东西的指示。github网站actions显示“此检查已跳过”。
如何让自托管运行器仅在标签为prj1的作业上部署项目
发布于 2021-10-07 15:33:09
基本上,我可以使用runs-on来指定哪个标签。所以我的yml文件现在看起来很像
name: Environment
on:
push:
branches:
- master
jobs:
p1:
runs-on: prj1
steps:
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event." >> deploy-log.txt这意味着在自托管github上,标记了prj1的运行者将运行该作业。
https://stackoverflow.com/questions/69370060
复制相似问题