-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
43 lines (40 loc) · 1.25 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
name: 'Install and Cache Terraform Plugin'
description: 'Installs Terraform plugin and cache it.'
inputs:
caching:
description: 'Whether to cache dependies or not.'
required: false
default: 'true'
tf-version:
description: 'The Terraform version to be used.'
required: true
default: 1.4
outputs:
used-cache:
description: 'Whether the cache was used.'
value: ${{ steps.install.outputs.cache }}
runs:
using: 'composite'
steps:
- name: Setup Terraform
uses: hashicorp/[email protected]
with:
terraform_version: inputs.tf-version
- name: Cache Terraform
if: inputs.caching == 'true'
id: cache
uses: actions/cache@v4
with:
path: |
~/.terraform.d/plugin-cache
key: ${{ runner.os }}-terraform-${{ hashFiles('**/.terraform.lock.hcl') }}
restore-keys: |
${{ runner.os }}-terraform-
- name: Config Terraform plugin cache
id: install
if: steps.cache.outputs.cache-hit != 'true' || inputs.caching != 'true'
run: |
echo 'plugin_cache_dir="$HOME/.terraform.d/plugin-cache"' >~/.terraformrc
mkdir --parents ~/.terraform.d/plugin-cache
echo "cache='${{ inputs.caching }}'" >> $GITHUB_OUTPUT
shell: bash