Display Name is not fully expanded for some contexts on skipped steps
Describe the bug We try to evaluate the name of a step many times during the course of a job. Whether or not that is successful depends on if we have access to all the correct context values at the time we are trying to evaluate. The very last evaluation is done just as we start a step, and is intended as a catch all to evaluate the step name if it hasn't been evaluated yet.
However, this catch all doesn't work if the step doesn't actually run. You can see in the workflow below skipped steps may or may not fully evaluate the name based on what contexts are used in the name.
Rather than doing this last evaluation as the step starts, maybe we should do it right before we evaluate the condition, so that we can ensure even for skipped steps this value gets updated.
One tricky note, we should ensure that this evaluation cannot fail (skipped steps should never turn to failed and cause a job to fail that would have otherwise succeeded). I'm not sure if this is something the tryEvaluateStepName function can do, but we will want to double check with incorrectly formatted syntax inside the {{ }} brackets. In the case where a name cannot be evaluated, it would be okay to fallback to the unevaluated name.
To Reproduce Run the workflow
name: Skipping Steps
on:
workflow_dispatch:
push:
jobs:
skippedstep:
env:
NPM_PACKAGE_ORG: "random-name"
strategy:
matrix:
os: ["windows","linux"]
runs-on: ubuntu-latest
steps:
- name: ${{ github.actor }}
run: echo "this is expanded"
if: false
- name: ${{ env.NPM_PACKAGE_ORG }}
run: echo "I'll be expanded"
- name: ${{ env.NPM_PACKAGE_ORG }}
if: false
run: echo "I'll not be expanded"
- name: ${{ matrix.os }}
run: echo "am expanded as well"
if: false
Expected behavior We should evaluate the step name even if we skip the step.
Resources
Here is where we evaluate the step name, we do it multiple times, the last being as soon as we run a step.
Here is the last place we evaluate step names (just in time)
Here is where we evaluate conditions for steps