-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
57 lines (49 loc) · 1.86 KB
/
action.yml
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
name: setup-infrastructure
description: Sets up runner environment for infrastructure code.
inputs:
terraform-version:
description: Terraform version to use
default: '1.5.3'
required: false
type: string
runs:
using: composite
steps:
- name: set helper variable
shell: bash
run: echo "${name}=${value}" >> $GITHUB_ENV
env:
name: my_terraform_zip_name
value: terraform_${{ inputs.terraform-version }}_linux_amd64.zip
# note: linux_amd64 will stay like that for a while, its tad too difficult to make it parametrized using
# runner context and the worthiness of it is questionable assuming we'll always use linux on x64 :)
- name: set helper variable
shell: bash
run: echo "${name}=${value}" >> $GITHUB_ENV
env:
name: my_terraform_dl_link
value: https://releases.hashicorp.com/terraform/${{ inputs.terraform-version }}/${{ env.my_terraform_zip_name }}
- uses: actions/cache@v3
id: cache-terraform
with:
path: terraform
key: terraform${{ inputs.terraform-version }}
restore-keys: terraform
- name: conditionally install terraform
shell: bash
if: steps.cache-terraform.outputs.cache-hit != 'true'
run: |
wget ${{ env.my_terraform_dl_link }}
unzip ${{ env.my_terraform_zip_name }}
rm ${{ env.my_terraform_zip_name }}
echo "$(pwd)" >> $GITHUB_PATH
- uses: actions/cache@v3
id: cache-lockfile
with:
path: .terraform
key: terraform${{ inputs.terraform-version }}-lockfile${{ hashFiles('**/.terraform.lock.hcl') }}
restore-keys: terraform${{ inputs.terraform-version }}-lockfile
- name: conditionally install dependencies
shell: bash
if: steps.cache-lockfile.outputs.cache-hit != 'true'
run: terraform init -backend=false