Skip to content

Commit 9d9ff27

Browse files
committed
[fix] empty GITHUB_OUTPUT
1 parent 93017d1 commit 9d9ff27

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

actions/aws-terraform-runner/action.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,21 +214,31 @@ runs:
214214
set -euo pipefail
215215
CMD="${{ inputs.tf_command }}"
216216
217-
WS_IN="${{ inputs.tf_workspace }}"
218-
if [[ -n "$WS_IN" ]]; then
219-
WS="$WS_IN"
217+
if [[ -n "${{ inputs.tf_workspace }}" ]]; then
218+
WS="${{ inputs.tf_workspace }}"
220219
else
221-
WS="$(terraform workspace show 2>/dev/null || echo default)"
220+
WS="$(terraform workspace show 2>/dev/null | tr -d '\r' | head -n1)"
221+
WS="${WS## }"; WS="${WS%% }"
222+
[[ -z "$WS" ]] && WS="default"
222223
fi
223224
224225
TFV="$(terraform version -json 2>/dev/null | sed -n 's/.*"terraform_version":"\([^"]*\)".*/\1/p')"
225226
[[ -z "$TFV" ]] && TFV="${{ inputs.tf_version }}"
226227
227-
{
228-
echo "terraform_command=$CMD"
229-
echo "workspace=$WS"
230-
echo "terraform_version=$TFV"
231-
} >> "$GITHUB_OUTPUT"
228+
write_output () {
229+
local name="$1"; shift
230+
local val="$1"
231+
local delim="__${name}_$(date +%s%N)__"
232+
{
233+
echo "${name}<<${delim}"
234+
printf "%s\n" "$val"
235+
echo "${delim}"
236+
} >> "$GITHUB_OUTPUT"
237+
}
238+
239+
write_output terraform_command "$CMD"
240+
write_output terraform_version "$TFV"
241+
write_output workspace "$WS"
232242
233243
- name: Terraform Summary
234244
if: inputs.show_summary != 'false'

0 commit comments

Comments
 (0)