Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: interpolate action input defaults #1376

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/runner/action_composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 }}