diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 7d78d0b1..e805a406 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -72,19 +72,20 @@ jobs: - name: Run flutter --version shell: bash run: flutter --version - test_with_cache: - runs-on: ubuntu-latest + test_cache: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Checkout uses: actions/checkout@v2 - - uses: actions/cache@v2 - with: - path: ${{ runner.tool_cache }}/flutter - key: flutter-2.5.0-stable - uses: ./ with: channel: stable flutter-version: 2.5.0 + cache: true + cache-key: key-20220110 - name: Run dart --version shell: bash run: dart --version diff --git a/README.md b/README.md index fd765b88..a9566107 100644 --- a/README.md +++ b/README.md @@ -146,18 +146,16 @@ jobs: - run: flutter build macos ``` -Integration with actions/cache: +Integration with `actions/cache`: ```yaml steps: - uses: actions/checkout@v2 -- uses: actions/cache@v2 - with: - path: ${{ runner.tool_cache }}/flutter - key: flutter-2.5.0-stable - uses: subosito/flutter-action@v2 with: channel: stable flutter-version: 2.5.0 + cache: true + cache-key: flutter # optional, change this to force refresh cache - run: flutter --version ``` diff --git a/action.yml b/action.yml index 96043296..a02274cb 100644 --- a/action.yml +++ b/action.yml @@ -12,8 +12,20 @@ inputs: description: 'The Flutter build release channel' required: false default: 'stable' + cache: + description: 'Cache the Flutter SDK' + required: false + cache-key: + description: 'Identifier for the Flutter SDK cache' + required: false + default: 'flutter' runs: using: 'composite' steps: + - if: ${{ inputs.cache == 'true' }} + uses: actions/cache@v2 + with: + path: ${{ runner.tool_cache }}/flutter + key: ${{ inputs.cache-key }}-${{ inputs.channel }}-${{ inputs.flutter-version }} - run: $GITHUB_ACTION_PATH/setup.sh ${{ inputs.channel }} ${{ inputs.flutter-version }} shell: bash