From 81c05545ac075638a662b92055c0928572ed0b96 Mon Sep 17 00:00:00 2001 From: Rishav Dhar <19497993+rdhar@users.noreply.github.com> Date: Mon, 21 Oct 2024 01:20:14 +0100 Subject: [PATCH] caching example Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com> --- .github/examples/pr_push_auth.yaml | 13 ++++++++++++- README.md | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/examples/pr_push_auth.yaml b/.github/examples/pr_push_auth.yaml index 5fb01631..cb32c8c9 100644 --- a/.github/examples/pr_push_auth.yaml +++ b/.github/examples/pr_push_auth.yaml @@ -1,5 +1,5 @@ --- -name: Trigger on pull_request (plan) and push (apply) events with Terraform and AWS authentication. +name: Trigger on pull_request (plan) and push (apply) events with Terraform, AWS authentication and caching. on: pull_request: @@ -27,6 +27,17 @@ jobs: aws-region: us-east-1 role-to-assume: ${{ secrets.AWS_ROLE }} + - name: Create cache + run: | + mkdir --parents $HOME/.terraform.d/plugin-cache + echo "TF_PLUGIN_CACHE_DIR=$HOME/.terraform.d/plugin-cache" >> $GITHUB_ENV + + - name: Cache TF + uses: actions/cache@v4 + with: + path: ~/.terraform.d/plugin-cache + key: cache-tf-${{ runner.os }}-${{ hashFiles('path/to/directory/.terraform.lock.hcl') }} + - name: Setup TF uses: hashicorp/setup-terraform@v3 diff --git a/README.md b/README.md index 98929f28..e2a2f603 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ The following workflows showcase common use cases, while a comprehensive list of
- Run on pull_request (plan) and push (apply) events with Terraform and AWS authentication. + Run on pull_request (plan) and push (apply) events with Terraform, AWS authentication and caching. Run on pull_request (plan) and merge_group (apply) events with OpenTofu in matrix strategy.