name: Upload Demo App on Firebase

on:
  workflow_dispatch:
    inputs:
      tester_groups:
        description: 'Comma-separated list of tester groups'
        required: true
        default: 'mifos-mobile-apps'
        type: string

  pull_request:
    types: [ labeled ]
    branches:
      - 'development'
      - 'master'

concurrency:
  group: firebase-${{ github.ref }}
  cancel-in-progress: true

jobs:
  upload_demo_app_on_firebase:
    name: Upload Demo App on Firebase
    runs-on: macos-latest
    if: github.event.label.name == 'firebase-test-on' || github.event_name == 'workflow_dispatch'
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: ☁️ Deploy Android App on Firebase
        uses: openMF/mifos-x-actionhub-android-firebase-publish@v1.0.0
        with:
          release_type: 'demo'
          android_package_name: 'cmp-android'
          keystore_file: ${{ secrets.ORIGINAL_KEYSTORE_FILE }}
          keystore_password: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }}
          keystore_alias: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }}
          keystore_alias_password: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }}
          google_services: ${{ secrets.GOOGLESERVICES }}
          firebase_creds: ${{ secrets.FIREBASECREDS }}
          tester_groups: ${{ inputs.tester_groups }}