gpt4 book ai didi

github - 如何根据标签名称运行作业

转载 作者:行者123 更新时间:2023-12-05 09:29:51 25 4
gpt4 key购买 nike

我有以下条件:

name: Build Image

on:
push:
pull_request:
workflow_dispatch:


jobs:

build-image: (This should be only if the tag contains "azure")
name: Build Image Job
runs-on: [ self-hosted ]

steps:
- uses: actions/checkout@v2

- name: Run Build Step
run: |
ANSIBLE_VERSION=$(cat VERSION)
docker images

jobs:

build-image: (This will be for everything else)
name: Build Image Job
runs-on: [ self-hosted ]

steps:
- uses: actions/checkout@v2

- name: Run Build Step
run: |
ANSIBLE_VERSION=$(cat VERSION)
docker images

如何实现?你如何引用作业中的标签?您如何处理变量并从中得出 if 规则?

最佳答案

您可以在 on 配置中使用正则表达式来触发基于标签名称的工作流。例如:

on:
push:
tags:
- '*azure*'

在作业或步骤级别,您可以使用 contains() 表达式:

jobs:
build-for-azure-tag:
name: build-for-azure-tag
runs-on: ubuntu-latest
if: github.ref_type == 'tag' && contains(github.ref_name, 'azure')

关于github - 如何根据标签名称运行作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70233593/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com