feat: impl cache hit outputs
What does this PR do?
This PR adds a new output, cache-hit, to the flutter-action. The cache-hit output indicates whether the cache was successfully hit during the setup process. This can help optimize workflows by conditionally executing subsequent steps based on cache status.
Why is this change necessary?
In our project, we manage a monorepo using melos. As part of our CI/CD pipeline, we run melos bs (bootstrap) every time to set up dependencies and link packages. However, this can be redundant when the cache is already valid.
With the cache-hit output, we can:
- Avoid unnecessary executions of melos bs when the cache is valid.
- Reduce build times and resource usage.
- Enhance workflow efficiency.
Example usage
Here’s how we plan to use the cache-hit output:
jobs:
build:
runs-on: ubuntu-latest
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.CACHE-HIT == 'false'
run: melos bs
- name: Continue with build
run: flutter build apk
Hi @anies1212! This looks like a great PR, thank you.
I'd like to ask you to:
- update README to document this new feature
- support both
CACHE-KEYandPUB-CACHE-KEY, i.e. have two separatecache-hitandpub-cache-hitoutputs.
@bartekpacia as this is also a feature i would be interested in, i cherry picked the commit from @anies1212 and created a new PR with your requested changes in #364.