Skip to content

What I am doing wrong here? #26314

What I am doing wrong here? #26314
Jun 6, 2022 · 2 answers

image

CODE:

  • name: If intention is to rollback
    if: ${{ github.event.inputs.intention == ‘rollback’ }}
    run: |
    echo “artifactname=${{ env.rollbackartifact }}” >> $GITHUB_ENV
    echo ${env:artifactname}

I am getting a bad substitution error, please help me. Is there anything wrong with this code?

background:
env.rollbackartifact is I am getting from an input field.

run: |
  echo "artifactname=${{ env.rollbackartifact }}" >> $GITHUB_ENV
  echo ${env:artifactname}

There are two problems here:

  1. You try to set an environment variable variable via GITHUB_ENV and use it in the same run step. That doesn’t work, writing to GITHUB_ENV affects following steps within the job.
  2. ${env:artifactname} isn’t valid Unix shell syntax. If you want to use the artifactname environment variable, the correct code is ${artifactname}.

Replies

2 suggested answers
run: |
  echo "artifactname=${{ env.rollbackartifact }}" >> $GITHUB_ENV
  echo ${env:artifactname}

There are two problems here:

  1. You try to set an environment variable variable via GITHUB_ENV and use it in the same run step. That doesn’t work, writing to GITHUB_ENV affects following steps within the job.
  2. ${env:artifactname} isn’t valid Unix shell syntax. If you want to use the artifactname environment variable, the correct code is ${artifactname}.
0 replies
Answer selected

Thanks for the solution.
I just removed the second line from Run step and it worked.

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