From 54ff40101b96edcaa9fc2cf6f7b8811d2e056512 Mon Sep 17 00:00:00 2001 From: Markus Wolf Date: Fri, 7 Oct 2022 12:31:07 +0200 Subject: [PATCH] fix: interpolate action input defaults This fixes the regression to interpolate input defaults which contain expressions. --- pkg/runner/action_composite.go | 5 ++++- .../uses-composite-with-inputs/action/action.yml | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/runner/action_composite.go b/pkg/runner/action_composite.go index 256d36ecfdd..9001b489505 100644 --- a/pkg/runner/action_composite.go +++ b/pkg/runner/action_composite.go @@ -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) } } diff --git a/pkg/runner/testdata/uses-composite-with-inputs/action/action.yml b/pkg/runner/testdata/uses-composite-with-inputs/action/action.yml index 0e3547546ac..82337d505c2 100644 --- a/pkg/runner/testdata/uses-composite-with-inputs/action/action.yml +++ b/pkg/runner/testdata/uses-composite-with-inputs/action/action.yml @@ -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 }}