docs icon indicating copy to clipboard operation
docs copied to clipboard

How to properly escape values for $GITHUB_ENV file

Open klinki opened this issue 4 years ago • 8 comments

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#environment-files

What part(s) of the article would you like to see updated?

I'm missing explanation how to properly escape values written to $GITHUB_ENV file. It would be also helpful to describe how this file is read.

Additional information

I'm writing this issue based on my current experience.

I'm trying to set environment variable with value which starts with $ and so far I haven't been able to do so. Please see following workflow file as example: https://github.com/klinki/github-actions-for-packages/blob/main/.github/workflows/test-env-vars.yml


Edited by maintainer

Content Plan

Here is the writer's content plant for this issue

klinki avatar Oct 06 '21 11:10 klinki

Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

welcome[bot] avatar Oct 06 '21 11:10 welcome[bot]

@klinki Thanks so much for opening an issue! I'll triage this for the team to take a look :eyes:

ramyaparimi avatar Oct 06 '21 12:10 ramyaparimi

Thanks for opening this issue! I'm not sure how to do this either, but I agree it would be helpful to document. I reached out to the Actions team to ask.

However, this question might be a better fit GitHub Support or GitHub Community.

skedwards88 avatar Nov 20 '21 00:11 skedwards88

Update: You can use single quotes instead of double quotes to achieve this. e.g. This worked for me:

    steps:
      - shell: pwsh
        run: |
          echo 'action_state=$yellow' >> $GITHUB_ENV
      - shell: pwsh
         run: |
           echo  IT IS '${{ env.action_state }}'

You or anyone else is welcome to open a PR to add this information to the docs.

skedwards88 avatar Nov 20 '21 00:11 skedwards88

Can I add it? :) if @klinki isn't making a PR then I can work on this :).

ArkaprabhaChakraborty avatar Oct 07 '22 19:10 ArkaprabhaChakraborty

@ArkaprabhaChakraborty please feel free to work on this, it has been a while and I'm quite out of a loop of this particular issue now.

klinki avatar Oct 15 '22 11:10 klinki

@ArkaprabhaChakraborty - You, or anyone else, are welcome to work on this!

Thanks for your interest in improving the docs!

cmwilson21 avatar Oct 17 '22 13:10 cmwilson21

Can I add it? :) if @klinki isn't making a PR then I can work on this :).

  • [ ] #-@

Rs4178 avatar Oct 17 '22 14:10 Rs4178