Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 2

Environment variable not resolve in my script

Solved! Go to Solution.

Hello. I use Github Actions and and faced a problem. I defined env variable like this:

- name: Publish with Gradle
env:
RELEASE_VERSION: ${GITHUB_REF:11}
uses: eskatos/gradle-command-action@v1
with:
gradle-version: current
arguments: test publish 

Than, I want to use my RELEASE_VERSION in my gradle script.

 

I try get it:

version = System.getenv('RELEASE_VERSION')  

 

but instead of getting the name of my tag, I get this variable as is, i.e.

 

version = ${GITHUB_REF:11}

 

 Why was the value not calculated and assigned to a variable? I expected to get:

 

version = 1.0.0

 

 

Job run on ubuntu-latest.

 

 

1 Reply
Highlighted
Solution
GitHub Partner
Message 2 of 2

Re: Environment variable not resolve in my script

When you set value for an nvironment variable, it doesn't support geting substring of another env. You need to run it in bash script and use set-env to create env: RELEASE_VERSION. 

Please see my example:

set-env.png

Note: Is your GITHUB_REF like refs/tags/1.0.0 or refs/heads/1.0.0? If it is the second one, then ${GITHUB_REF:11} is right.