Which expression correctly checks whether the current branch name contains the substring 'release'?
Select an answer to reveal the explanation.
Short Explanation and Infographic
GitHub Actions expressions use contains() for substring checks — JavaScript methods like includes() and regex operators like ~ are not valid expression syntax in workflow if conditions.
Full explanation below image
Full Explanation
The contains() function is a built-in GitHub Actions expression function that returns true when the second argument is found as a substring of the first. github.ref_name holds the short branch or tag name (for example main or release/1.2). Using contains(github.ref_name, 'release') is therefore the idiomatic way to gate steps or jobs for release branches. github.ref_name.includes('release') is JavaScript method syntax and is not valid inside ${{ }}. match() is not a GitHub Actions expression function (though startsWith and endsWith exist). The ~ operator is a PostgreSQL/regex-style construct and is not part of the Actions expression language. Prefer contains, startsWith, and endsWith for string checks in if: conditions.