feat(CI): optimize workflows for Dart/Flutter with DRY principle and … #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Deploy to Netlify | |
| on: | |
| push: | |
| branches: [main] | |
| tags: | |
| - "*" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| verify: | |
| uses: ./.github/workflows/reusable_verify.yaml | |
| with: | |
| working-directory: example | |
| run-tests: true | |
| secrets: inherit | |
| deploy: | |
| needs: verify | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| flutter-version: ${{ secrets.FLUTTER_VERSION }} | |
| cache: true | |
| - name: Cache Pub dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.pub-cache | |
| key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pub- | |
| - name: Disable analytics | |
| run: flutter config --no-analytics | |
| - name: Install dependencies | |
| run: flutter pub get | |
| working-directory: example | |
| - name: Build web app | |
| run: flutter build web | |
| working-directory: example | |
| - name: Deploy to Netlify | |
| uses: nwtgck/actions-netlify@v3.0 | |
| with: | |
| publish-dir: "./example/build/web" | |
| production-branch: master | |
| production-deploy: true | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |