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'
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With