Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,38 @@ dynamic values:
- `:hash:`
- `:sha256:`

### Using cache outputs

> [!NOTE]
> `PUB-CACHE-HIT` and `CACHE-HIT` directly use the `cache-hit` output from `actions/cache@v4`, which is the following:
> - `cache-hit` - A string value to indicate an exact match was found for the key.
> - If there's a cache hit, this will be 'true' or 'false' to indicate if there's an exact match for `key`.
> - If there's a cache miss, this will be an empty string.

Example usage (inspired by [actions/cache@v4](https://github.com/actions/cache/blob/c45d39173a637a28edbd526cb160189cc4e84f5a/README.md#skipping-steps-based-on-cache-hit) and [#346](https://github.com/subosito/flutter-action/pull/346)) to skip `melos bootstrap` if there was a pub cache hit:

```
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Flutter
uses: subosito/flutter-action@v2
id: flutter-action
with:
channel: stable
cache: true

- name: Conditionally run melos bootstrap
if: steps.flutter-action.outputs.PUB-CACHE-HIT != 'true'
run: melos bootstrap

- name: Continue with build
run: flutter build apk
```

## Outputs

Use outputs from `flutter-action`:

```yaml
Expand All @@ -338,6 +370,8 @@ steps:
echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }}
echo PUB-CACHE-PATH=${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
echo PUB-CACHE-KEY=${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}
echo CACHE-HIT=${{ steps.flutter-action.outputs.CACHE-HIT }}
echo PUB-CACHE-HIT=${{ steps.flutter-action.outputs.PUB-CACHE-HIT }}
```

If you don't need to install Flutter and just want the outputs, you can use the
Expand All @@ -361,7 +395,11 @@ steps:
echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }}
echo PUB-CACHE-PATH=${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
echo PUB-CACHE-KEY=${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}
echo CACHE-HIT=${{ steps.flutter-action.outputs.CACHE-HIT }}
echo PUB-CACHE-HIT=${{ steps.flutter-action.outputs.PUB-CACHE-HIT }}
shell: bash
```
[Alif Rachmawadi]: https://github.com/subosito
[Bartek Pacia]: https://github.com/bartekpacia

[Alif Rachmawadi](https://github.com/subosito)

[Bartek Pacia](https://github.com/bartekpacia)
Comment on lines -366 to +405
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these lines did not show up in the README, so i changed to links that do show up

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

Copy link
Collaborator

@bartekpacia bartekpacia Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, they were actually supposed to not show up. they are link reference definitions.

see https://github.github.com/gfm/#link-reference-definitions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, my bad 😅. thanks for explaining!

8 changes: 8 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ outputs:
GIT_SOURCE:
value: "${{ steps.flutter-action.outputs.GIT_SOURCE }}"
description: Git source of Flutter SDK repository to clone
CACHE-HIT:
value: "${{ steps.cache-flutter.outputs.cache-hit }}"
description: "`true` if the flutter cache was a hit"
PUB-CACHE-HIT:
value: "${{ steps.cache-pub.outputs.cache-hit }}"
description: "`true` if the pub cache was a hit"

runs:
using: composite
Expand Down Expand Up @@ -109,6 +115,7 @@ runs:
${{ inputs.channel }}

- name: Cache Flutter
id: cache-flutter
uses: actions/cache@v4
if: ${{ inputs.cache == 'true' }}
with:
Expand All @@ -117,6 +124,7 @@ runs:

- name: Cache pub dependencies
uses: actions/cache@v4
id: cache-pub
if: ${{ inputs.cache == 'true' }}
with:
path: ${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
Expand Down