Echo not outputting variable value

Viewed 37

I am trying to print value of API_RESPONSE but it prints "response is: ". S3_RESPONSE value is set but API_RESPONSE shows blank in echo command.

  - name: Check if certificate exists
    id: check_certificate
    run: |
      API_RESPONSE=$(aws s3api head-object --bucket test-bucket-ssl --key fullchain.pem 2>&1 | tee true)
      echo "::set-output name=S3_RESPONSE::$(echo $API_RESPONSE)"
      echo "response is: ${API_RESPONSE}"
2 Answers

I think, instead of

response is: ${API_RESPONSE}

you should use

response is: ${{API_RESPONSE}}

You might need to use an environment file, as illustrate here.
In your case:

  - name: Check if certificate exists (Set the value)
    id: Check if certificate exists_set_value
    run: |
        echo "API_RESPONSE=$(aws s3api head-object --bucket test-bucket-ssl --key fullchain.pem 2>&1 | tee true)" >> $GITHUB_ENV
  - name: Check if certificate exists (Use the value)
    id: Check if certificate exists_use_value
    run: |
        echo "API_RESPONSE=${{ env.API_RESPONSE}}"
Related