# Conditional Step from tag regex

**URL:** <https://community.codefresh.io/t/conditional-step-from-tag-regex/549>\
**Category:** Pipeline Workflows\
**Created:** [May 20, 2021, 5:37pm UTC](https://community.codefresh.io/t/conditional-step-from-tag-regex/549 "2021-05-20T17:37:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Pham](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/anthony_pham/32/294_2.png) [@Anthony\_Pham](https://community.codefresh.io/u/Anthony_Pham)\
**Post date:** [May 20, 2021, 5:37pm UTC](https://community.codefresh.io/t/conditional-step-from-tag-regex/549/1 "2021-05-20T17:37:24Z")

</div>

Hello,

I’m trying to trigger builds based on a regex for a tag on github.

I’ve tried both of these, but it appears to not work as it doesn’t show up in the build workflow. To my understanding CF\_BRANCH returns the tag name but I’m not sure what I’m doing wrong for these conditions to pass. The tag is “dev-test1”

> ```
> test_dev_only:
> title: "Packaging project"
> image: codefresh/build-cli
> type: "freestyle"
> stage: "Prepare"
> commands:
> - echo "This works"
> when:
> branch:
> only:
> - /^((dev))-.*/gi
> test_dev_only:
> title: "Packaging dev project"
> image: codefresh/build-cli
> type: "freestyle"
> stage: "Prepare"
> commands:
> - echo "This works dev"
> when:
> condition:
> all:
> executeForDevTags: "match('${{CF_BRANCH}}','^((dev))-.*\\i',true)"
> 
> ```

---

<div class="post-metadata">

**Author:** ![Anthony\_Pham](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/anthony_pham/32/294_2.png) [@Anthony\_Pham](https://community.codefresh.io/u/Anthony_Pham)\
**Post date:** [May 20, 2021, 6:30pm UTC](https://community.codefresh.io/t/conditional-step-from-tag-regex/549/2 "2021-05-20T18:30:09Z")

</div>

> [@Anthony\_Pham](#):
>
> ```auto
> when:
> condition:
> all:
> executeForDevTags: "match('${{CF_BRANCH}}','^((dev))-.*\\i',true)"
> 
> ```

Looks like the build step wasn’t showing due to tabbing under an existing step, interesting that it didn’t fail for an unknown key value.

But anywho I can test the condition how, however it appears that my match is failing  
match(‘dev-test3’,‘^((dev))-.\*\i’,true) evaluates to false. I’ll try more things but when using a regex tester that string does match.

---

<div class="post-metadata">

**Author:** ![Anthony\_Pham](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/anthony_pham/32/294_2.png) [@Anthony\_Pham](https://community.codefresh.io/u/Anthony_Pham)\
**Post date:** [May 20, 2021, 6:44pm UTC](https://community.codefresh.io/t/conditional-step-from-tag-regex/549/3 "2021-05-20T18:44:18Z")

</div>

I discovered that the issue is that I’m attempting to set a flag within the match for ignore case, but match already takes a param to ignore case (third arg). It is now working as intended!

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [May 21, 2021, 7:25am UTC](https://community.codefresh.io/t/conditional-step-from-tag-regex/549/4 "2021-05-21T07:25:25Z")

</div>

I am glad it works out for you.

Let us know if you have other questions.

Welcome to the Codefresh community!
