Given a GitHub workflow that looks something like this:
name: Test variable usage
on:
workflow_dispatch:
env:
STEP_NAME_01 : "Say hello"
FRIENDLY_NAME : Joan
HELLO_VERSION : develop
jobs:
execute-hello-action-job:
name: execute-hello-action-job
runs-on: ubuntu-latest
steps:
- name: ${{STEP_NAME_01}} ## <<--- This is where I would like to use a variable
uses: github/no_repository_provided/hello-world@develop
with:
friendly_name: ${FRIENDLY_NAME}
Is there a syntax that would let me supply the name of the step as a variable?
Given a GitHub workflow that looks something like this:
name: Test variable usage
on:
workflow_dispatch:
env:
STEP_NAME_01 : "Say hello"
FRIENDLY_NAME : Joan
HELLO_VERSION : develop
jobs:
execute-hello-action-job:
name: execute-hello-action-job
runs-on: ubuntu-latest
steps:
- name: ${{STEP_NAME_01}} ## <<--- This is where I would like to use a variable
uses: github/no_repository_provided/hello-world@develop
with:
friendly_name: ${FRIENDLY_NAME}
Is there a syntax that would let me supply the name of the step as a variable?
Share Improve this question edited Mar 15 at 3:05 hakre 198k55 gold badges449 silver badges856 bronze badges asked Mar 14 at 22:09 vscodervscoder 1,0411 gold badge14 silver badges33 bronze badges 2 |1 Answer
Reset to default 2There's a handy table in the documentation showing which context is available where. For jobs.<job_id>.steps.name
, the contexts are github
, needs
, strategy
, matrix
, job
, runner
, env
, vars
, secrets
, steps
, inputs
.
In your case, you want to use a workflow-level environment variable. Those are accessible via the env
context:
steps:
- name: ${{ env.STEP_NAME_01 }}
uses: github/no_repository_provided/hello-world@develop
with:
friendly_name: ${{ env.FRIENDLY_NAME }}
name
value, the available contexts aregithub
,needs
,strategy
,matrix
,job
,runner
,env
,vars
,secrets
,steps
,inputs
. What value do you want to supply? – Benjamin W. Commented Mar 15 at 2:57