Terraform provider cache example #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Terraform cache example | |
on: | |
workflow_dispatch: | |
jobs: | |
main: | |
name: Example | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_version: 1.3.0 | |
- name: Config Terraform plugin cache | |
run: | | |
echo 'plugin_cache_dir="$HOME/.terraform.d/plugin-cache"' >~/.terraformrc | |
mkdir --parents ~/.terraform.d/plugin-cache | |
- name: Cache Terraform | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.terraform.d/plugin-cache | |
key: ${{ runner.os }}-terraform-${{ hashFiles('**/.terraform.lock.hcl') }} | |
restore-keys: | | |
${{ runner.os }}-terraform- | |
- name: Init example Terraform configuration | |
run: | | |
terraform init |