question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support environment variables and bash expressions in file names

See original GitHub issue

It would be great to be able to use environment variables and the output of bash expressions like below:

- name: Prepare GitHub Release
  run: mv some.file some.file-$GITHUB_SHA-$(git describe --tags --exact-match)
- name: Release to GitHub Releases
  uses: docker://softprops/action-gh-release
  if: startsWith(github.ref, 'refs/tags/')
  with:
    files: some.file-$GITHUB_SHA-$(git describe --tags --exact-match)
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tenzapcommented, Mar 17, 2022

It would be easier if access to environment vars, as well as to $HOME or ~ was available.

It took me some time to figure out this workaround: put the environment var you need into the env context, and the use that.

To put the environment var you need into the env context, add this a step of your job:

echo "my_home=$HOME" >> $GITHUB_ENV

Then in softprops/action-gh-release@v1 step you can use it like this:

  with:
    files: ${{ env.my_home }}/aFile

Maybe this can help someone.

1reaction
tulercommented, Oct 9, 2019

If you don’t have the exact string you want in a GitHub context variable, you can use a step to create an output with the value you need. Example:

- run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//''}
  id: release
- uses: softprops/action-gh-release@v1
  with:
    files: some.file-${{ steps.release.outputs.version }}.tar.gz
    env:
      GITHUB_TOKEN: ${{ secrets.CI_TOKEN }}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use variables in a filename? - Unix StackExchange
In this case Bash interprets domain_ as the name of the variable to expand. It's a valid name for a variable. Expanding this...
Read more >
A Complete Guide to the Bash Environment Variables
A complete guide on the Linux Bash environment variables with details on how to set, unset, and use the specials shell variables or...
Read more >
3.2. Variables
Global variables or environment variables are available in all shells. The env or printenv commands can be used to display environment variables.
Read more >
Bash Reference Manual - GNU.org
Your users will use the LANG or LC_MESSAGES shell variables to select the desired language. You set the TEXTDOMAIN variable to the script's ......
Read more >
Assign file names to a variable in shell - bash - Stack Overflow
I want each name of a list of files in a directory to be assigned to a variable (the same variable, one at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found