upload-release-action icon indicating copy to clipboard operation
upload-release-action copied to clipboard

Environment Variable in File Name

Open Myoldmopar opened this issue 4 years ago • 2 comments

It could be more of a design question, but are environment variables supposed to be applied in the name field?

This was a snippet from my workflow:

    - name: Upload SH to release
      uses: svenstaro/upload-release-action@v2
      with:
        repo_token: ${{ secrets.GITHUB_TOKEN }}
        file: ${{runner.workspace}}/EnergyPlus/build/${{ matrix.os }}_$PACKAGE_NAME_SH
        tag: ${{ github.ref }}
        overwrite: true

The double bracketed things were of course filled in when the file was processed by Github. The $PACKAGE_NAME_SH environment variable was set by using proper action commands dynamically just above this (echo ::set-env name=PACKAGE_NAME_SH::...). But when this action ran, the $PACKAGE_NAME_SH was left as-is, and of course, it couldn't find the package name which would have matched if that field had been replaced with the actual environment variable value.

Right now I can get it to work if I just file glob for the artifact name, but it zips the single file up, and I want the package uploaded in raw form. I'm trying to dynamically specify the exact filename and just need this environment variable to be populated with its value.

Thanks!

Myoldmopar avatar Sep 16 '20 14:09 Myoldmopar

Did you try ${{ env.PACKAGE_NAME_SH}}? See also: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions

svenstaro avatar Sep 25 '20 03:09 svenstaro

Thank you, I had the same issue but @svenstaro's suggestion helped me. After reading the GitHub Actions docs, I'm still a bit unsure about the difference between $MY_ENV_VAR and ${{ env.MY_ENV_VAR }}. I understand the latter can be evaluated by GitHub anywhere, but what about the former? Do I understand correctly that it only works in the run commands, same as if it was a shell?

ba32107 avatar Oct 17 '20 08:10 ba32107