@@ -167,6 +167,11 @@ inputs:
167
167
description : " Leverage actions/cache to cache dependencies to speed up execution"
168
168
required : false
169
169
default : ' false'
170
+ terraform-cache-dir :
171
+ description : " allows overriding of the terraform cache dir which defaults to ${github.workspace}/cache"
172
+ required : false
173
+ default : ' '
174
+
170
175
digger-spec :
171
176
description : " (orchestrator only) the spec to pass onto digger cli"
172
177
required : false
@@ -247,11 +252,21 @@ runs:
247
252
subscription-id : ${{ inputs.azure-subscription-id }}
248
253
if : ${{ inputs.setup-azure == 'true' && inputs.azure-client-id != '' }}
249
254
255
+ # if terraform-cache-dir is set then we set it to that otherwise set it to '${{github.workspace}}/cache'
256
+ - name : retrieve cache dir
257
+ shell : bash
258
+ run : |
259
+ CACHE_DIR=${{ inputs.terraform-cache-dir == '' &&
260
+ format('{0}/cache', github.workspace) ||
261
+ inputs.terraform-cache-dir }}
262
+ echo "TF_PLUGIN_CACHE_DIR=$CACHE_DIR" >> $GITHUB_ENV
263
+ echo "TERRAGRUNT_PROVIDER_CACHE_DIR=$CACHE_DIR" >> $GITHUB_ENV
264
+
250
265
- uses : actions/cache/restore@v4
251
266
id : restore_cache
252
267
name : restore_cache
253
268
with :
254
- path : ${{ github.workspace }}/cache
269
+ path : $TF_PLUGIN_CACHE_DIR
255
270
key : digger-cache
256
271
restore-keys : |
257
272
digger-cache
@@ -346,6 +361,7 @@ runs:
346
361
mkdir -p $GITHUB_WORKSPACE/cache
347
362
shell : bash
348
363
364
+
349
365
- name : build and run digger
350
366
if : ${{ !startsWith(github.action_ref, 'v') }}
351
367
shell : bash
@@ -369,9 +385,7 @@ runs:
369
385
INPUT_DRIFT_DETECTION_SLACK_NOTIFICATION_URL : ${{ inputs.drift-detection-slack-notification-url }}
370
386
NO_BACKEND : ${{ inputs.no-backend }}
371
387
DEBUG : ' true'
372
- TF_PLUGIN_CACHE_DIR : ${{ github.workspace }}/cache
373
388
TERRAGRUNT_PROVIDER_CACHE : ${{ inputs.cache-dependencies == 'true' && 1 || 0 }}
374
- TERRAGRUNT_PROVIDER_CACHE_DIR : ${{ github.workspace }}/cache
375
389
DIGGER_RUN_SPEC : ${{inputs.digger-spec}}
376
390
run : |
377
391
if [[ ${{ inputs.ee }} == "true" ]]; then
@@ -407,9 +421,7 @@ runs:
407
421
INPUT_DIGGER_COMMAND : ${{ inputs.command }}
408
422
INPUT_DRIFT_DETECTION_SLACK_NOTIFICATION_URL : ${{ inputs.drift-detection-slack-notification-url }}
409
423
NO_BACKEND : ${{ inputs.no-backend }}
410
- TF_PLUGIN_CACHE_DIR : ${{ github.workspace }}/cache
411
424
TERRAGRUNT_PROVIDER_CACHE : ${{ inputs.cache-dependencies == 'true' && 1 || 0 }}
412
- TERRAGRUNT_PROVIDER_CACHE_DIR : ${{ github.workspace }}/cache
413
425
DIGGER_RUN_SPEC : ${{inputs.digger-spec}}
414
426
id : digger
415
427
shell : bash
@@ -428,7 +440,7 @@ runs:
428
440
name : cache-save
429
441
if : ${{ always() && inputs.cache-dependencies == 'true' && steps.restore_cache.outputs.cache-hit != 'true' }}
430
442
with :
431
- path : ${{ github.workspace }}/cache
443
+ path : $TF_PLUGIN_CACHE_DIR
432
444
key : digger-cache-${{ hashFiles('**/cache') }}
433
445
434
446
branding :
0 commit comments