My CD workflow failing with error: conditional binary operator expected

Viewed 22

So I don't know much about bash script, one of my step in CD workflow is to set the environment according to the branch we are pushing into but the command is failing with the error

if [[  == 'main' ]]; then
  echo "ENVIRONMENT_NAME=production" >> "$GITHUB_ENV"
fi
if [[  == 'qa' ]]; then
  echo "ENVIRONMENT_NAME=qa" >> "$GITHUB_ENV"
fi
if [[  == 'dev' ]]; then
  echo "ENVIRONMENT_NAME=development" >> "$GITHUB_ENV"
fi
shell: /usr/bin/bash -e {0}
/home/runner/work/_temp/e934d539-5b6a-4b49-b539-e567b3e1ce77.sh: line 1: conditional 
binary operator expected
Error: Process completed with exit code 2.

Here is my step code

- name: Set env.ENVIRONMENT_NAME
    run: |
      if [[ ${{ steps.vars.outputs.branch }} == 'main' ]]; then
          echo "ENVIRONMENT_NAME=production" >> "$GITHUB_ENV"
      fi
      if [[ ${{ steps.vars.outputs.branch }} == 'qa' ]]; then
          echo "ENVIRONMENT_NAME=qa" >> "$GITHUB_ENV"
      fi
      if [[ ${{ steps.vars.outputs.branch }} == 'dev' ]]; then
          echo "ENVIRONMENT_NAME=development" >> "$GITHUB_ENV"
      fi

as you can see its not picking up the steps.vars.outputs.branch. heres my step of setting up the github branch, if its any help

       - name: Set branch name
       id: vars
       run: echo ::set-output name=stage::${GITHUB_REF#refs/*/}

I am clueless here. Any suggestion where my step is going wrong?

0 Answers
Related