From f51c7b30b96cb81313e2f972fe623a3a25caf04c Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 6 Feb 2024 22:07:11 +0100 Subject: [PATCH] add continuous deployment to firebase --- .firebaserc | 5 ++ .github/workflows/on-commit-main.yml | 79 +++++++++++++++++++ .../workflows/{default.yml => on-commit.yml} | 2 +- firebase.json | 16 ++++ 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 .firebaserc create mode 100644 .github/workflows/on-commit-main.yml rename .github/workflows/{default.yml => on-commit.yml} (98%) create mode 100644 firebase.json diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..d78c42e --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "flutter-map-plugins" + } +} diff --git a/.github/workflows/on-commit-main.yml b/.github/workflows/on-commit-main.yml new file mode 100644 index 0000000..cf0f20b --- /dev/null +++ b/.github/workflows/on-commit-main.yml @@ -0,0 +1,79 @@ +name: Test & Build `main` +on: + push: + branches: [ main ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + name: Build Android + steps: + - name: Checkout project + uses: actions/checkout@v3 + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Install melos + run: dart pub global activate melos + - name: Install coverde + run: dart pub global activate coverde + - name: Bootstrap melos + run: melos bootstrap + - name: Run tests with coverage + run: melos run test_with_coverage --no-select + - name: Run Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + build-android: + runs-on: ubuntu-latest + name: Build Android + needs: [ test ] + steps: + - name: Checkout project + uses: actions/checkout@v3 + - name: Setup Java + uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '21' + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Build APK + working-directory: example + run: flutter build apk + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: apk + path: example/build/app/outputs/flutter-apk/app-release.apk + build-web: + runs-on: ubuntu-latest + needs: [ test ] + if: github.repository == 'josxha/flutter_map_plugins' + defaults: + run: + working-directory: ./example + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Build Web + run: flutter build web + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_FLUTTER_MAP_PLUGINS }}' + channelId: live + projectId: flutter-map-plugins + diff --git a/.github/workflows/default.yml b/.github/workflows/on-commit.yml similarity index 98% rename from .github/workflows/default.yml rename to .github/workflows/on-commit.yml index d0d2a5e..e9eea87 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/on-commit.yml @@ -1,7 +1,7 @@ name: Test & Build on: push: - branches: [ main ] + branches-ignore: [ main ] pull_request: branches: [ main ] diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..6adbf8c --- /dev/null +++ b/firebase.json @@ -0,0 +1,16 @@ +{ + "hosting": { + "public": "example/build/web", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } +}