Skip to content

If (not) startswith mutually exclusive steps #26386

If (not) startswith mutually exclusive steps #26386
Nov 5, 2020 · 4 answers
Discussion options

You must be logged in to vote

@valentijnscholten,

You are using the incorrect expression syntax for the if conditional in your workflow.
Change them like as this can work:

- name: Create release branch
  if: ${{ !startsWith(github.event.inputs.from_branch, 'release/') }}
  run: |
    echo "NEW_BRANCH=release/${{ github.event.inputs.release_number }}" >> $GITHUB_ENV
  • name: Use existing release branch
    if: ${{ startsWith(github.event.inputs.from_branch, 'release/') }}
    run: |
    echo "NEW_BRANCH=${{ github.event.inputs.from_branch }}" >> $GITHUB_ENV

There are few points you need to know when setting if conditionals (jobs.<job_id>.if or jobs.<job_id>.steps.if) in your workflow:

  1. If you want to use the expression syntax “${{ }}

Replies: 4 suggested answers

Comment options

You must be logged in to vote
0 replies
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants