Skip to content

Commit e3257ce

Browse files
committed
feat: custom cache support
Adding support for custom cache actions. They must be a drop in replacement for actions/cache for it to work properly
1 parent 0ca7a94 commit e3257ce

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

action.yaml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ inputs:
5050
description: Git clone source
5151
required: false
5252
default: "https://github.com/flutter/flutter.git"
53+
custom-cache-action:
54+
description: Path to a custom caching action that will be executed for flutter cache instead of the default caching mechanism. It must be a drop-in replacement for actions/cache.
55+
required: false
56+
default: ""
57+
custom-pub-cache-action:
58+
description: Path to a custom caching action that will be executed for pub cache instead of the default caching mechanism. It must be a drop-in replacement for actions/cache.
59+
required: false
60+
default: ""
5361

5462
outputs:
5563
CHANNEL:
@@ -77,10 +85,10 @@ outputs:
7785
value: "${{ steps.flutter-action.outputs.GIT_SOURCE }}"
7886
description: Git source of Flutter SDK repository to clone
7987
CACHE-HIT:
80-
value: "${{ steps.cache-flutter.outputs.cache-hit }}"
88+
value: "${{ fromJSON(steps.cache-flutter.outputs.outputs || '{}').cache-hit }}"
8189
description: "`true` if the flutter cache was a hit"
8290
PUB-CACHE-HIT:
83-
value: "${{ steps.cache-pub.outputs.cache-hit }}"
91+
value: "${{ fromJSON(steps.cache-pub.outputs.outputs || '{}').cache-hit }}"
8492
description: "`true` if the pub cache was a hit"
8593

8694
runs:
@@ -116,19 +124,23 @@ runs:
116124
117125
- name: Cache Flutter
118126
id: cache-flutter
119-
uses: actions/cache@v5
120-
if: ${{ inputs.cache == 'true' }}
121-
with:
122-
path: ${{ steps.flutter-action.outputs.CACHE-PATH }}
123-
key: ${{ steps.flutter-action.outputs.CACHE-KEY }}
127+
uses: jenseng/dynamic-uses@v1
128+
if: ${{ inputs.cache == 'true' || inputs.custom-cache-action != '' }}
129+
with:
130+
uses: ${{ inputs.custom-cache-action == '' && 'actions/cache@v5' || inputs.custom-cache-action }}
131+
with: |
132+
path: ${{ toJSON(steps.flutter-action.outputs.CACHE-PATH) }}
133+
key: '${{ steps.flutter-action.outputs.CACHE-KEY }}'
124134
125135
- name: Cache pub dependencies
126-
uses: actions/cache@v5
127136
id: cache-pub
128-
if: ${{ inputs.cache == 'true' }}
137+
if: ${{ inputs.cache == 'true' || inputs.custom-pub-cache-action != '' }}
138+
uses: jenseng/dynamic-uses@v1
129139
with:
130-
path: ${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
131-
key: ${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}
140+
uses: ${{ inputs.custom-pub-cache-action == '' && 'actions/cache@v5' || inputs.custom-pub-cache-action }}
141+
with: |
142+
path: ${{ toJSON(steps.flutter-action.outputs.PUB-CACHE-PATH) }}
143+
key: '${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}'
132144
133145
- name: Run setup script
134146
shell: bash

0 commit comments

Comments
 (0)