Skip to content

Commit 2b28ed0

Browse files
authored
gh-actions/cache/prime: Fix conditions for cache type selection (#2987)
Signed-off-by: Ryan Northey <[email protected]>
1 parent fa612f9 commit 2b28ed0

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

gh-actions/cache/prime/action.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ inputs:
55
artifact-wf-path:
66
type: string
77
default:
8+
cache-type:
9+
type: string
10+
default: github
11+
description: |
12+
Cache type, should be one of "github", "gcs", "artifact"
813
change-directory:
914
type: boolean
1015
default: true
@@ -47,6 +52,7 @@ outputs:
4752
cached:
4853
value: ${{ steps.cache-restore.outputs.cache-hit }}
4954

55+
5056
runs:
5157
using: "composite"
5258
steps:
@@ -62,15 +68,16 @@ runs:
6268
# Initial checks
6369
- name: Check GCS bucket cache
6470
id: gcs-object
65-
if: inputs.gcs-bucket
71+
if: >-
72+
inputs.cache-type == 'gcs'
6673
uses: envoyproxy/toolshed/gh-actions/gcs/cache/[email protected]
6774
with:
6875
bucket: ${{ inputs.gcs-bucket }}
6976
key: ${{ inputs.key }}
7077
- name: Check artifact cache
7178
id: artifact-object
7279
if: >-
73-
! inputs.gcs-bucket
80+
inputs.cache-type == 'artifact'
7481
uses: envoyproxy/toolshed/gh-actions/github/artifact/cache/[email protected]
7582
with:
7683
name: ${{ inputs.key }}
@@ -79,8 +86,7 @@ runs:
7986
- name: Check cache
8087
id: cache-restore-initial
8188
if: >-
82-
! inputs.gcs-bucket
83-
&& ! inputs.artifact-name
89+
inputs.cache-type == 'github'
8490
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
8591
with:
8692
lookup-only: true
@@ -117,8 +123,7 @@ runs:
117123
if: >-
118124
inputs.lock-token
119125
&& steps.cache-restore-initial.outputs.cache-hit != 'true'
120-
&& ! inputs.gcs-bucket
121-
&& ! inputs.artifact-name
126+
&& inputs.cache-type == 'github'
122127
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
123128
with:
124129
lookup-only: true
@@ -127,7 +132,7 @@ runs:
127132
- name: Recheck artifacts
128133
id: artifact-object-recheck
129134
if: >-
130-
! inputs.gcs-bucket
135+
inputs.cache-type == 'artifact'
131136
&& steps.artifact-object.outputs.exists == ''
132137
uses: envoyproxy/toolshed/gh-actions/github/artifact/cache/[email protected]
133138
with:
@@ -136,7 +141,7 @@ runs:
136141
- name: Check GCS bucket cache
137142
id: gcs-object-recheck
138143
if: >-
139-
inputs.gcs-bucket
144+
inputs.cache-type == 'gcs'
140145
&& steps.gcs-object.outputs.exists != 'true'
141146
uses: envoyproxy/toolshed/gh-actions/gcs/cache/[email protected]
142147
with:
@@ -195,8 +200,7 @@ runs:
195200
196201
- if: >-
197202
steps.restore.outputs.save == 'true'
198-
&& ! inputs.gcs-bucket
199-
&& ! inputs.artifact-name
203+
&& inputs.cache-type == 'github'
200204
name: Save cache
201205
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
202206
with:
@@ -215,13 +219,15 @@ runs:
215219
- name: Save archive cache
216220
if: >-
217221
steps.restore.outputs.save == 'true'
218-
&& inputs.artifact-name
222+
&& inputs.cache-type == 'artifact'
219223
uses: envoyproxy/toolshed/gh-actions/github/artifact/cache/[email protected]
220224
with:
221225
name: ${{ inputs.artifact-name }}
222226
path: ${{ inputs.path || inputs.path-tmp }}
223227

224-
- if: ${{ steps.restore.outputs.save == 'true' && ! inputs.path }}
228+
- if: >-
229+
steps.restore.outputs.save == 'true'
230+
&& ! inputs.path
225231
run: |
226232
# Remove temporary files
227233
if [[ "${{ inputs.mount-tmpfs }}" == 'true' ]]; then

0 commit comments

Comments
 (0)