-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yaml
85 lines (75 loc) · 3.08 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
name: BuildNow Terraform Init
description: Initiate Terraform with Sync as HTTP backend. [Documentation](https://github.com/zingdevlimited/actions-helpers/blob/v3/docs/usage/composite-actions-buildnow.md#terraform-init-with-twilio-backend)
inputs:
PLUGIN_NAME:
required: true
description: Name of the BuildNow Plugin
TERRAFORM_DIRECTORY:
required: true
description: The path to the Terraform root directory
TWILIO_API_KEY:
required: true
description: The Twilio API key
TWILIO_API_SECRET:
required: true
description: The Twilio API secret
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
BACKEND_PROXY_PORT:
required: false
description: |
(Optional) Override the port used to host the local proxy server for Terraform backend operations.
Set this if the default port conflicts with other steps in the current runner/job.
Defaults to 9464
default: "9464"
# Obsolete Inputs
TERRAFORM_BASIC_USERNAME:
required: false
description: (OBSOLETE) No longer has an effect
TERRAFORM_BASIC_PASSWORD:
required: false
description: (OBSOLETE) No longer has an effect
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.TERRAFORM_DIRECTORY }}" ]] && echo "::error::Missing TERRAFORM_DIRECTORY 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: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false
- name: Start Backend Proxy
uses: zingdevlimited/actions-helpers/build-now/terraform-init/backend-proxy@v3
with:
PLUGIN_NAME: ${{ inputs.PLUGIN_NAME }}
BACKEND_PROXY_PORT: ${{ inputs.BACKEND_PROXY_PORT }}
TWILIO_API_KEY: ${{ inputs.TWILIO_API_KEY }}
TWILIO_API_SECRET: ${{ inputs.TWILIO_API_SECRET }}
SYNC_SERVICE_SID: ${{ inputs.SYNC_SERVICE_SID }}
SYNC_MAP_NAME: ${{ inputs.SYNC_MAP_NAME }}
ACTION_PATH: ${{ github.action_path }}
- name: Terraform Init
shell: bash
working-directory: ${{ inputs.TERRAFORM_DIRECTORY }}
run: terraform init -backend-config="address=http://localhost:${{ env.CURRENT_BACKEND_PROXY_PORT }}"
- name: Terraform Validate
shell: bash
working-directory: ${{ inputs.TERRAFORM_DIRECTORY }}
run: terraform validate