|
| 1 | +name: Deploy staging and production to Firebase App Distribution |
| 2 | + |
| 3 | +on: |
| 4 | + # Trigger the workflow on push action in main branch. |
| 5 | + # So it will trigger when the PR of the feature branch was merged. |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + |
| 10 | +jobs: |
| 11 | + deploy_staging_and_production_to_firebase_app_distribution: |
| 12 | + name: Deploy staging and production to Firebase App Distribution |
| 13 | + runs-on: ubuntu-latest |
| 14 | + timeout-minutes: 30 |
| 15 | + steps: |
| 16 | + - name: Set up JDK 17 |
| 17 | + uses: actions/setup-java@v3 |
| 18 | + with: |
| 19 | + distribution: 'temurin' |
| 20 | + java-version: '17' |
| 21 | + |
| 22 | + - name: Set up timezone |
| 23 | + uses: zcong1993/setup-timezone@master |
| 24 | + with: |
| 25 | + timezone: Asia/Bangkok |
| 26 | + |
| 27 | + - name: Checkout source code |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Cache Gradle |
| 31 | + uses: actions/cache@v2 |
| 32 | + with: |
| 33 | + path: | |
| 34 | + ~/.gradle/caches/modules-* |
| 35 | + ~/.gradle/caches/jars-* |
| 36 | + ~/.gradle/caches/build-cache-* |
| 37 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} |
| 38 | + restore-keys: | |
| 39 | + ${{ runner.os }}-gradle- |
| 40 | +
|
| 41 | + - name: Run Detekt |
| 42 | + run: ./gradlew detekt |
| 43 | + |
| 44 | + - name: Archive Detekt reports |
| 45 | + uses: actions/upload-artifact@v3 |
| 46 | + with: |
| 47 | + name: DetektReports |
| 48 | + path: build/reports/detekt/ |
| 49 | + |
| 50 | + - name: Run unit tests with Kover |
| 51 | + run: ./gradlew koverHtmlReport |
| 52 | + |
| 53 | + - name: Archive code coverage reports |
| 54 | + uses: actions/upload-artifact@v3 |
| 55 | + with: |
| 56 | + name: CodeCoverageReports |
| 57 | + path: app/build/reports/kover/ |
| 58 | + |
| 59 | + - name: Build production APK |
| 60 | + run: ./gradlew assembleProductionRelease |
| 61 | + |
| 62 | + - name: Deploy production to Firebase |
| 63 | + uses: wzieba/Firebase-Distribution-Github-Action@v1 |
| 64 | + with: |
| 65 | + appId: ${{secrets.FIREBASE_APP_ID_PRODUCTION}} |
| 66 | + serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CREDENTIAL_FILE_CONTENT }} |
| 67 | + groups: testers |
| 68 | + file: app/build/outputs/apk/production/debug/app-production-release.apk |
0 commit comments