Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment Variable in File Name #30

Open
Myoldmopar opened this issue Sep 16, 2020 · 2 comments
Open

Environment Variable in File Name #30

Myoldmopar opened this issue Sep 16, 2020 · 2 comments

Comments

@Myoldmopar
Copy link

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!

@svenstaro
Copy link
Owner

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

@ba32107
Copy link

ba32107 commented Oct 17, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants