Search code examples
githubgitpython

How (and why) upgrade a GitHub workflow to use “Environment files”


I have a GitHub action workflow file that is running fine, but recently warnings about ‘set-env’ and ‘add-path’ deprecation have been brought to my attention. The fix suggested by GitHub is to use “Environment Files”; I.e. pipe values into a file managed by a GITHUB_ENV file descriptor.

My question is : Is GitHub asking me to replace the “env” block of my workflow with a step containing commands of the form ‘echo “{name}={value}" >> $GITHUB_ENV’?

I have to also ask why this is necessary, since I think it is lame, but that is really beside the point.


Solution

  • From my experience using python with GitHub actions, this is an issue with actions/setup-python versions 1.1.1 and earlier. You probably have a line in your workflow that reads:

    uses: actions/[email protected]
    

    If you upgrade to version 2 of setup-python, there will be no warning. Just change the line above to the following:

    uses: actions/setup-python@v2
    

    In order to demonstrate, the log of my v1.1.1 workflow shows the warnings you mentioned, but the warnings are resolved by using version 2