Describe the bug
The format function seems to not work when passing an expression as second argument. As shown in the workflow file below, calling format('https://{0}.app.com', 'prod') returns https://prod.app.com as described in the docs. However, in my use case the second argument needs to be a variable so I can set the value on the fly. In order to achieve this, I'm using another actions (actually two) which set TARGET to either prod or stage based on whether the workflow runs on master or not.
Now I'm struggle to consume this output in the format function. Passing it as an expression seems to resolve the value, but does not substitute the actual string.
My attempt:
format('https://{0}.app.com', '${{ steps.env_target_prod.outputs.TARGET || steps.env_target_stage.outputs.TARGET }}')
Actual output:
format('https://{0}.app.com', 'prod')
Expected output:
To Reproduce
Note, I use the echo command as noop, since Actions require a run or uses field. Also I do the expression within the name field just for the sake of this example. In my actual action this is an field that is required by one of my actions.
Workflow file:
Details
name: Build
on:
push
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: 'Set environment target to stage'
id: 'env_target_stage'
if: github.ref != 'refs/heads/master'
run: echo "::set-output name=TARGET::stage"
- name: 'Set environment target to production'
id: 'env_target_prod'
if: github.ref == 'refs/heads/master'
run: echo "::set-output name=TARGET::prod"
- name: ${{ format('https://{0}.app.com', 'prod') }}
# Output: https://prod.app.com
run: echo
- name: format('https://{0}.app.com', '${{ steps.env_target_prod.outputs.TARGET || steps.env_target_stage.outputs.TARGET }}')
# Output: format('https://{0}.app.com', 'prod')
run: echo
- name: ${{ format('https://{0}.app.com', '${{ steps.env_target_prod.outputs.TARGET || steps.env_target_stage.outputs.TARGET }}') }}
# Output: https://${{ steps.env_target_prod.outputs.TARGET || steps.env_target_stage.outputs.TARGET }}.app.com
run: echo
I hope this is enough information to reproduce the issue.
Describe the bug
The
formatfunction seems to not work when passing an expression as second argument. As shown in the workflow file below, callingformat('https://{0}.app.com', 'prod')returnshttps://prod.app.comas described in the docs. However, in my use case the second argument needs to be a variable so I can set the value on the fly. In order to achieve this, I'm using another actions (actually two) which setTARGETto eitherprodorstagebased on whether the workflow runs onmasteror not.Now I'm struggle to consume this output in the format function. Passing it as an expression seems to resolve the value, but does not substitute the actual string.
My attempt:
Actual output:
Expected output:
To Reproduce
Note, I use the
echocommand as noop, since Actions require arunorusesfield. Also I do the expression within thenamefield just for the sake of this example. In my actual action this is an field that is required by one of my actions.Workflow file:
Details
I hope this is enough information to reproduce the issue.