Skip to content

Run step on (if branch/tag is) #25216

Answered by BradenM
bhowell2 asked this question in Actions
Nov 19, 2019 · 8 comments · 4 replies
Discussion options

You must be logged in to vote

Hi @bhowell2,

First, you do not need to use conditional syntax with the “if” statement. See the following excerpt from: "About context and expressions"

When you use expressions in an if conditional, you do not need to use the expression syntax ({{ }}) because GitHub automatically evaluates the if conditional as an expression.

As for pattern matching with the if statement, I suggest using the contains function. Here’s an example:

if: contains(github.ref, "release")
steps:
 - run: echo "I only run if the branch has release in its name!"

Replies: 8 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@karlhorky
Comment options

@gamesguru
Comment options

@sankansm23
Comment options

Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@patrickelectric
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet