-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yaml
48 lines (45 loc) · 1.51 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
name: Gogaille setup terraform
description: >
Setup terraform by:
1. Downloading required version if needed
2. Initializing it
inputs:
terraform-version:
description: Terraform required version
required: true
default: "0.14.0"
workspace-key-prefix:
description: >
Path to the state file inside the S3 Bucket.
[Learn more by reading terraform documentation](https://www.terraform.io/docs/backends/types/s3.html#key)
default: "preproduction"
required: true
working-directory:
description: working directory
required: true
default: "."
runs:
using: "composite"
steps:
- name: terraform install
shell: bash
run: |
dpkg --compare-versions ${{ inputs.terraform-version }} eq $(terraform --version | head -n1 | cut -d'v' -f2) && exit 0
curl -qs https://releases.hashicorp.com/terraform/"${{ inputs.terraform-version }}"/terraform_"${{ inputs.terraform-version }}"_linux_amd64.zip | \
gunzip - | \
sudo tee /usr/local/bin/terraform > /dev/null
sudo chmod +x /usr/local/bin/terraform
terraform --version
- name: terraform init
shell: bash
run: |
terraform init \
-input=false \
-backend-config "workspace_key_prefix=${{ inputs.workspace-key-prefix }}" \
-reconfigure \
-backend=true \
-upgrade
working-directory: ${{ inputs.working-directory }}
- run: terraform get
shell: bash
working-directory: ${{ inputs.working-directory }}