Skip to content

Commit 5d287f3

Browse files
committed
Add cache for pub dependencies
1 parent 4bcff39 commit 5d287f3

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

action.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ then
3232
FLUTTER_OS="${FLUTTER_OS}_$ARCH"
3333
fi
3434

35-
# Flutter runner tool cache
35+
# Flutter runner tool cache and pub cache
3636
# path: "${{ runner.tool_cache }}/flutter-${{ runner.os }}-${{ inputs.version }}-${{ runner.arch }}"
3737
# key: flutter-action-setup-flutter-${{ runner.os }}-${{ inputs.version }}-${{ runner.arch }}
3838
FLUTTER_RUNNER_TOOL_CACHE="${RUNNER_TOOL_CACHE}/flutter-${RUNNER_OS}-${FLUTTER_VERSION}-${RUNNER_ARCH}"
39+
FLUTTER_PUB_CACHE="${RUNNER_TEMP}/pub-cache"
3940

4041
# Check if Flutter SDK already exists
4142
# Otherwise download and install
@@ -88,10 +89,10 @@ else
8889
fi
8990

9091
# Configure pub to use a fixed location.
91-
echo "PUB_CACHE=${HOME}/.pub-cache" >> $GITHUB_ENV
92+
echo "PUB_CACHE=${FLUTTER_PUB_CACHE}" >> $GITHUB_ENV
9293

9394
# Update paths.
94-
echo "${HOME}/.pub-cache/bin" >> $GITHUB_PATH
95+
echo "${FLUTTER_PUB_CACHE}/bin" >> $GITHUB_PATH
9596
echo "${FLUTTER_RUNNER_TOOL_CACHE}/flutter/bin" >> $GITHUB_PATH
9697

9798
# Report success, and print version.

action.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
required: false
1414
default: "stable"
1515
cache:
16+
description: 'Cache the pub dependencies. Default: false'
17+
required: false
18+
default: "false"
19+
cache-sdk:
1620
description: 'Cache the installed Flutter SDK. Default: false'
1721
required: false
1822
default: "false"
@@ -23,10 +27,18 @@ inputs:
2327
runs:
2428
using: "composite"
2529
steps:
26-
- if: ${{ inputs.cache == 'true' }}
30+
# Cache the Flutter SDK
31+
- if: ${{ inputs.cache-sdk == 'true' }}
2732
uses: actions/cache@v3
2833
with:
2934
path: ${{ runner.tool_cache }}/flutter-${{ runner.os }}-${{ inputs.version }}-${{ runner.arch }}
3035
key: flutter-action-setup-flutter-${{ runner.os }}-${{ inputs.version }}-${{ inputs.channel }}-${{ runner.arch }}-${{ inputs.cache-key }}
36+
# Cache the pub dependencies
37+
- if: ${{ inputs.cache == 'true' }}
38+
uses: actions/cache@v3
39+
with:
40+
path: ${{ runner.temp }}/pub-cache
41+
key: flutter-action-setup-flutter-${{ runner.os }}-${{ inputs.version }}-${{ inputs.channel }}-${{ runner.arch }}-${{ inputs.cache-key }}-pub-cache
42+
# Run the action
3143
- run: $GITHUB_ACTION_PATH/action.sh ${{ inputs.version }} ${{ inputs.channel }}
3244
shell: bash

0 commit comments

Comments
 (0)