From 964f748ed328df252e8222a972eeb65a23ab0c49 Mon Sep 17 00:00:00 2001 From: Joshua Jackson Date: Wed, 20 Mar 2024 08:52:51 -0400 Subject: [PATCH 1/8] add caching behaviors as an option to the action --- action.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/action.yml b/action.yml index 930d77b45..139b97182 100644 --- a/action.yml +++ b/action.yml @@ -137,6 +137,10 @@ inputs: description: 'drift-detection slack drift url' required: false default: '' + cache-dependencies: + description: 'Leverage actions/cache to cache dependencies to speed up execution" + required: false + default: 'false' outputs: output: value: ${{ steps.digger.outputs.output }} @@ -212,6 +216,17 @@ runs: subscription-id: ${{ inputs.azure-subscription-id }} if: ${{ inputs.setup-azure == 'true' && inputs.azure-client-id != '' }} + - uses: actions/cache/restore@v4 + id: restore_cache + name: restore_cache + with: + path: ${{ github.workspace }}/cache + key: ${{ runner.os }}-cache-${{ hashFiles('**/cache') }} + restore-keys: | + ${{ runner.os }}-cache-${{ hashFiles('**/cache') }} + ${{ runner.os }}-cache + if: ${{ inputs.cache-dependencies == 'true' }} + - name: Setup Terraform uses: hashicorp/setup-terraform@v3 with: @@ -262,6 +277,9 @@ runs: core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN']) core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL']) + - name: create cache dir + run: | + mkdir -p $GITHUB_WORKSPACE/cache - name: build and run digger if: ${{ !startsWith(github.action_ref, 'v') }} @@ -282,6 +300,7 @@ runs: INPUT_DRIFT_DETECTION_SLACK_NOTIFICATION_URL: ${{ inputs.drift-detection-slack-drift-url }} NO_BACKEND: ${{ inputs.no-backend }} DEBUG: 'true' + TF_PLUGIN_CACHE_DIR: ${{ github.workspace }}/cache run: | cd $GITHUB_ACTION_PATH/cli go build -o digger ./cmd/digger @@ -315,6 +334,12 @@ runs: PATH=$PATH:$(pwd) cd $GITHUB_WORKSPACE digger + + - uses: actions/cache/save@v4 + name: cache-save + with: + path: ${{ github.workspace }}/cache + key: ${{ runner.os }}-${{ hashFiles('**/cache') }} branding: icon: globe color: purple From 4d9c42fb00573e01e7b72d1c7f366205f25b9ae3 Mon Sep 17 00:00:00 2001 From: Joshua Jackson <40365668+JoshuaJackson-jobvite@users.noreply.github.com> Date: Wed, 20 Mar 2024 10:20:02 -0400 Subject: [PATCH 2/8] fix: mixed if on the cache-save --- action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yml b/action.yml index 139b97182..731fe1193 100644 --- a/action.yml +++ b/action.yml @@ -340,6 +340,8 @@ runs: with: path: ${{ github.workspace }}/cache key: ${{ runner.os }}-${{ hashFiles('**/cache') }} + if: ${{ inputs.cache-dependencies == 'true' }} + branding: icon: globe color: purple From 1404e80032c0186b7a796e1d2f4bfbc0040a271e Mon Sep 17 00:00:00 2001 From: Joshua Jackson <40365668+JoshuaJackson-jobvite@users.noreply.github.com> Date: Thu, 25 Apr 2024 09:55:41 -0700 Subject: [PATCH 3/8] Update action.yml Co-authored-by: Mohamed Habib --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 646491e0e..9b6e2f88c 100644 --- a/action.yml +++ b/action.yml @@ -138,7 +138,7 @@ inputs: required: false default: '' cache-dependencies: - description: 'Leverage actions/cache to cache dependencies to speed up execution" + description: "Leverage actions/cache to cache dependencies to speed up execution" required: false default: 'false' outputs: From 8cc76d0121f9a006a7e3da9d6285ecbe07869205 Mon Sep 17 00:00:00 2001 From: Joshua Jackson <40365668+JoshuaJackson-jobvite@users.noreply.github.com> Date: Thu, 25 Apr 2024 09:55:56 -0700 Subject: [PATCH 4/8] Update action.yml Co-authored-by: Mohamed Habib --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 9b6e2f88c..1bab25f63 100644 --- a/action.yml +++ b/action.yml @@ -280,6 +280,7 @@ runs: - name: create cache dir run: | mkdir -p $GITHUB_WORKSPACE/cache + shell: bash - name: build and run digger if: ${{ !startsWith(github.action_ref, 'v') }} From deb845b31c72a110835916777f7f252210850d7e Mon Sep 17 00:00:00 2001 From: Joshua Jackson <40365668+JoshuaJackson-jobvite@users.noreply.github.com> Date: Fri, 26 Apr 2024 09:26:45 -0700 Subject: [PATCH 5/8] Update action.yml Co-authored-by: Mohamed Habib --- action.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 1bab25f63..6eff93dff 100644 --- a/action.yml +++ b/action.yml @@ -221,10 +221,9 @@ runs: name: restore_cache with: path: ${{ github.workspace }}/cache - key: ${{ runner.os }}-cache-${{ hashFiles('**/cache') }} + key: digger-cache restore-keys: | - ${{ runner.os }}-cache-${{ hashFiles('**/cache') }} - ${{ runner.os }}-cache + digger-cache if: ${{ inputs.cache-dependencies == 'true' }} - name: Setup Terraform From c72c5a93cac66ff5b22c22ccb753abe480d04782 Mon Sep 17 00:00:00 2001 From: Joshua Jackson <40365668+JoshuaJackson-jobvite@users.noreply.github.com> Date: Fri, 26 Apr 2024 09:26:50 -0700 Subject: [PATCH 6/8] Update action.yml Co-authored-by: Mohamed Habib --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 6eff93dff..902e87523 100644 --- a/action.yml +++ b/action.yml @@ -339,7 +339,7 @@ runs: name: cache-save with: path: ${{ github.workspace }}/cache - key: ${{ runner.os }}-${{ hashFiles('**/cache') }} + key: digger-${{ hashFiles('**/cache') }} if: ${{ inputs.cache-dependencies == 'true' }} branding: From 318b4b780249ce3151e8885cdd424239360d161a Mon Sep 17 00:00:00 2001 From: Joshua Jackson <40365668+JoshuaJackson-jobvite@users.noreply.github.com> Date: Fri, 26 Apr 2024 12:48:08 -0700 Subject: [PATCH 7/8] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 902e87523..bbb2ab4bd 100644 --- a/action.yml +++ b/action.yml @@ -339,7 +339,7 @@ runs: name: cache-save with: path: ${{ github.workspace }}/cache - key: digger-${{ hashFiles('**/cache') }} + key: digger-cache-${{ hashFiles('**/cache') }} if: ${{ inputs.cache-dependencies == 'true' }} branding: From da6c5cf3e0631f5819afdb5f9b98140c1061384e Mon Sep 17 00:00:00 2001 From: Joshua Jackson <40365668+JoshuaJackson-jobvite@users.noreply.github.com> Date: Fri, 26 Apr 2024 12:49:15 -0700 Subject: [PATCH 8/8] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index bbb2ab4bd..c76764136 100644 --- a/action.yml +++ b/action.yml @@ -339,7 +339,7 @@ runs: name: cache-save with: path: ${{ github.workspace }}/cache - key: digger-cache-${{ hashFiles('**/cache') }} + key: digger-cache-${{ hashFiles('**/cache') }} if: ${{ inputs.cache-dependencies == 'true' }} branding: