forked from zingdevlimited/actions-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
88 lines (81 loc) · 2.92 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: BuildNow Terraform Output
description: Get Terraform Outputs from Twilio Sync backend. [Documentation](https://github.com/zingdevlimited/actions-helpers/blob/v3/docs/usage/composite-actions-buildnow.md#terraform-output-with-twilio-backend)
inputs:
PLUGIN_NAME:
required: true
description: Name of the BuildNow Plugin
TWILIO_API_KEY:
required: true
description: The Twilio API key
TWILIO_API_SECRET:
required: true
description: The Twilio API secret
EXPORT_OUTPUTS:
required: false
default: "null"
description: Comma-separated list of output values to export to GITHUB_ENV
SYNC_SERVICE_SID:
required: false
description: |
(Optional) Override the Sync Service Sid for where the Terraform state file is stored.
Defaults to the Default Sync Service `default`
default: default
SYNC_MAP_NAME:
required: false
description: |
(Optional) Override the Sync Map UniqueName for where the Terraform state file is stored.
Defaults to `build-now-state-manager-files`
default: build-now-state-manager-files
NO_ERROR_ON_MISSING:
required: false
description: |
(Optional) Set to `true` to not error if the state file is not found
# Obsolete Inputs
TERRAFORM_DIRECTORY:
required: false
description: (OBSOLETE) No longer has an effect
TERRAFORM_BASIC_USERNAME:
required: false
description: (OBSOLETE) No longer has an effect
TERRAFORM_BASIC_PASSWORD:
required: false
description: (OBSOLETE) No longer has an effect
outputs:
TERRAFORM_OUTPUTS:
description: The Terraform output JSON
value: ${{ steps.tfOutput.outputs.RESULT }}
runs:
using: composite
steps:
- name: Validate Inputs
shell: bash
run: |
fail=""
[[ -z "${{ inputs.PLUGIN_NAME }}" ]] && echo "::error::Missing PLUGIN_NAME in inputs" && fail=1
[[ -z "${{ inputs.TWILIO_API_KEY }}" ]] && echo "::error::Missing TWILIO_API_KEY in inputs" && fail=1
[[ -z "${{ inputs.TWILIO_API_SECRET }}" ]] && echo "::error::Missing TWILIO_API_SECRET in inputs" && fail=1
[[ -n "$fail" ]] && exit 1 || exit 0
- name: Get Terraform Outputs
id: tfOutput
shell: bash
run: |
${{ github.action_path }}/get-outputs.sh \
"${{ inputs.PLUGIN_NAME }}" \
"${{ inputs.SYNC_SERVICE_SID }}" \
"${{ inputs.SYNC_MAP_NAME }}" \
"${{ inputs.NO_ERROR_ON_MISSING }}"
env:
TWILIO_API_KEY: ${{ inputs.TWILIO_API_KEY }}
TWILIO_API_SECRET: ${{ inputs.TWILIO_API_SECRET }}
- name: Export Outputs
if: inputs.EXPORT_OUTPUTS != 'null'
shell: bash
run: |
IFS=',' read -ra variables <<< "${{ inputs.EXPORT_OUTPUTS }}"
for var in "${variables[@]}"
do
value=$(echo "$TF_OUTPUTS" | jq -r ".$var.value")
echo "$var=$value" >> "$GITHUB_ENV"
done
env:
TF_OUTPUTS: ${{ steps.tfOutput.outputs.RESULT }}