flutter-action icon indicating copy to clipboard operation
flutter-action copied to clipboard

feat: impl cache hit outputs

Open anies1212 opened this issue 11 months ago • 1 comments

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


anies1212 avatar Jan 24 '25 04:01 anies1212

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-KEY and PUB-CACHE-KEY, i.e. have two separate cache-hit and pub-cache-hit outputs.

bartekpacia avatar Mar 24 '25 20:03 bartekpacia

@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.

beninato8 avatar Jun 13 '25 06:06 beninato8