Reputation: 1641
I'd like to reuse an env variable defined in the same section.
This does not work
env:
HOST: example.com
URL: $HOST/foo.html
It will just yield a verbose "$HOST/foo.html" without host being resolved when used.
I also tried
env:
HOST: example.com
URL: ${{ env.HOST }}/foo.html
this just tells me unrecognized named-value: 'env'
Upvotes: 3
Views: 1935
Reputation: 14776
According to this GitHub Actions forum thread, you can't.
The proposed solution there is to set the base environment variable, at the job level, and then you can use it at the step level.
jobs:
test:
runs-on: ubuntu-latest
name: Test
env:
HOST: example.com
steps:
- env:
URL: ${{ env.HOST }}/foo.html
run: echo $URL
I agree with your intuition - I also expected it to work.
Upvotes: 6