fix: interpolate action input defaults (#1376)
This fixes the regression to interpolate input defaults which contain expressions.
This commit is contained in:
parent
48188a6280
commit
36310139e0
2 changed files with 14 additions and 1 deletions
|
@ -21,6 +21,8 @@ func evaluateCompositeInputAndEnv(ctx context.Context, parent *RunContext, step
|
|||
}
|
||||
}
|
||||
|
||||
ee := parent.NewStepExpressionEvaluator(ctx, step)
|
||||
|
||||
for inputID, input := range step.getActionModel().Inputs {
|
||||
envKey := regexp.MustCompile("[^A-Z0-9-]").ReplaceAllString(strings.ToUpper(inputID), "_")
|
||||
envKey = fmt.Sprintf("INPUT_%s", strings.ToUpper(envKey))
|
||||
|
@ -31,7 +33,8 @@ func evaluateCompositeInputAndEnv(ctx context.Context, parent *RunContext, step
|
|||
if value, ok := stepEnv[envKey]; defined && ok {
|
||||
env[envKey] = value
|
||||
} else {
|
||||
env[envKey] = input.Default
|
||||
// defaults could contain expressions
|
||||
env[envKey] = ee.Interpolate(ctx, input.Default)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@ inputs:
|
|||
some:
|
||||
description: "some input"
|
||||
required: true
|
||||
other:
|
||||
description: "other input"
|
||||
default: "${{ inputs.some }}"
|
||||
required: false
|
||||
outputs:
|
||||
out:
|
||||
description: "some output"
|
||||
|
@ -17,3 +21,9 @@ runs:
|
|||
echo "action input=${{ inputs.some }}"
|
||||
[[ "${{ inputs.some == 'value' }}" = "true" ]] || exit 1
|
||||
shell: bash
|
||||
- run: |
|
||||
echo "ENV_VAR=$ENV_VAR"
|
||||
[[ "$ENV_VAR" = "value" ]] || exit 1
|
||||
shell: bash
|
||||
env:
|
||||
ENV_VAR: ${{ inputs.other }}
|
||||
|
|
Loading…
Reference in a new issue