Skip to content

Commit

Permalink
refactor out variable setting
Browse files Browse the repository at this point in the history
  • Loading branch information
motatoes committed Jan 20, 2025
1 parent 814b105 commit a0c734f
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions action.yml
Original file line number Diff line number Diff line change
@@ -256,11 +256,21 @@ runs:
subscription-id: ${{ inputs.azure-subscription-id }}
if: ${{ inputs.setup-azure == 'true' && inputs.azure-client-id != '' }}

# if terraform-cache-dir is set then we set it to that otherwise set it to '${{github.workspace}}/cache'
- name: retrieve cache dir
shell: bash
run: |
CACHE_DIR=${{ inputs.terraform-cache-dir == '' &&
format('{0}/cache', github.workspace) ||
inputs.terraform-cache-dir }}
echo "TF_PLUGIN_CACHE_DIR=$CACHE_DIR" >> $GITHUB_ENV
echo "TERRAGRUNT_PROVIDER_CACHE_DIR=$CACHE_DIR" >> $GITHUB_ENV
- uses: actions/cache/restore@v4
id: restore_cache
name: restore_cache
with:
path: ${{ github.workspace }}/cache
path: $TF_PLUGIN_CACHE_DIR
key: digger-cache
restore-keys: |
digger-cache
@@ -355,6 +365,7 @@ runs:
mkdir -p $GITHUB_WORKSPACE/cache
shell: bash


- name: build and run digger
if: ${{ !startsWith(github.action_ref, 'v') }}
shell: bash
@@ -378,14 +389,7 @@ runs:
INPUT_DRIFT_DETECTION_SLACK_NOTIFICATION_URL: ${{ inputs.drift-detection-slack-notification-url }}
NO_BACKEND: ${{ inputs.no-backend }}
DEBUG: 'true'
# if terraform-cache-dir is set then we set it to that otherwise set it to '${{github.workspace}}/cache'
TF_PLUGIN_CACHE_DIR: ${{ inputs.terraform-cache-dir == '' &&
format('{0}/cache', github.workspace) ||
inputs.terraform-cache-dir }}
TERRAGRUNT_PROVIDER_CACHE: ${{ inputs.cache-dependencies == 'true' && 1 || 0 }}
TERRAGRUNT_PROVIDER_CACHE_DIR: ${{ inputs.terragrunt-cache-dir == '' &&
format('{0}/cache', github.workspace) ||
inputs.terragrunt-cache-dir }}
DIGGER_RUN_SPEC: ${{inputs.digger-spec}}
run: |
if [[ ${{ inputs.ee }} == "true" ]]; then
@@ -421,15 +425,7 @@ runs:
INPUT_DIGGER_COMMAND: ${{ inputs.command }}
INPUT_DRIFT_DETECTION_SLACK_NOTIFICATION_URL: ${{ inputs.drift-detection-slack-notification-url }}
NO_BACKEND: ${{ inputs.no-backend }}
# if terraform-cache-dir is set then we set it to that otherwise set it to '${{github.workspace}}/cache'
TF_PLUGIN_CACHE_DIR: ${{ inputs.terraform-cache-dir == '' &&
format('{0}/cache', github.workspace) ||
inputs.terraform-cache-dir }}
TERRAGRUNT_PROVIDER_CACHE: ${{ inputs.cache-dependencies == 'true' && 1 || 0 }}
# if terragrunt-cache-dir is set then we set it to that otherwise set it to '${{github.workspace}}/cache'
TERRAGRUNT_PROVIDER_CACHE_DIR: ${{ inputs.terragrunt-cache-dir == '' &&
format('{0}/cache', github.workspace) ||
inputs.terragrunt-cache-dir }}
DIGGER_RUN_SPEC: ${{inputs.digger-spec}}
id: digger
shell: bash
@@ -448,7 +444,7 @@ runs:
name: cache-save
if: ${{ always() && inputs.cache-dependencies == 'true' && steps.restore_cache.outputs.cache-hit != 'true' }}
with:
path: ${{ github.workspace }}/cache
path: $TF_PLUGIN_CACHE_DIR
key: digger-cache-${{ hashFiles('**/cache') }}

branding:

0 comments on commit a0c734f

Please sign in to comment.