diff --git a/.github/actions/generate-firebase-options/action.yaml b/.github/actions/generate-firebase-options/action.yaml new file mode 100644 index 0000000..c409ae0 --- /dev/null +++ b/.github/actions/generate-firebase-options/action.yaml @@ -0,0 +1,44 @@ +name: "Generate Firebase Options" +description: "Generate Firebase Options" +inputs: + firebase_service_account_json: + description: 'Firebase service account JSON' + required: true + firebase_project_id: + description: 'Firebase project ID' + required: true +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + + - name: Configure Firebase Credentials + shell: bash + run: | + cat << EOF > service_account.json +${{ inputs.firebase_service_account_json }} +EOF + export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/service_account.json + + - name: Debug Environment Variables + shell: bash + run: | + echo "Current working directory: $(pwd)" + env | grep GOOGLE_APPLICATION_CREDENTIALS + ls -l + cat service_account.json # Very important to check the file content + + - name: Test Firebase Authentication + shell: bash + run: firebase projects:list --project ${{ inputs.firebase_project_id }} + + - name: Generate Options File + shell: bash + run: | + firebase use ${{ inputs.firebase_project_id }} --non-interactive + firebase apps:sdks --platform=android,ios,web > lib/firebase_options.dart + + - name: Clean up + shell: bash + if: always() + run: rm service_account.json \ No newline at end of file diff --git a/.github/workflows/default-workflow.yaml b/.github/workflows/default-workflow.yaml index 5a8435f..51390d7 100644 --- a/.github/workflows/default-workflow.yaml +++ b/.github/workflows/default-workflow.yaml @@ -15,6 +15,12 @@ jobs: - name: Prepare runner uses: ./.github/actions/prepare-ubuntu-runner + - name: Generate Firebase options + uses: ./.github/actions/generate-firebase-options + with: + firebase_service_account_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }} + firebase_project_id: ${{ secrets.FIREBASE_PROJECT_ID }} + - name: Run virtual machine tests run: bundle exec fastlane run_vm_tests @@ -28,6 +34,12 @@ jobs: - name: Prepare runner uses: ./.github/actions/prepare-ubuntu-runner + - name: Generate Firebase options + uses: ./.github/actions/generate-firebase-options + with: + firebase_service_account_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }} + firebase_project_id: ${{ secrets.FIREBASE_PROJECT_ID }} + - name: Build debug uses: ./.github/actions/build-android with: @@ -45,6 +57,12 @@ jobs: - name: Prepare runner uses: ./.github/actions/prepare-macos-runner + - name: Generate Firebase options + uses: ./.github/actions/generate-firebase-options + with: + firebase_service_account_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }} + firebase_project_id: ${{ secrets.FIREBASE_PROJECT_ID }} + - name: Decode and save .env file run: echo "${{ secrets.ENV_FILE }}" | base64 -d > .env diff --git a/.github/workflows/release-workflow.yaml b/.github/workflows/release-workflow.yaml index c098d2c..ad37bf3 100644 --- a/.github/workflows/release-workflow.yaml +++ b/.github/workflows/release-workflow.yaml @@ -15,6 +15,12 @@ jobs: - name: Prepare runner uses: ./.github/actions/prepare-ubuntu-runner + - name: Generate Firebase options + uses: ./.github/actions/generate-firebase-options + with: + firebase_service_account_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }} + firebase_project_id: ${{ secrets.FIREBASE_PROJECT_ID }} + - name: Run virtual machine tests run: bundle exec fastlane run_vm_tests @@ -28,6 +34,12 @@ jobs: - name: Prepare runner uses: ./.github/actions/prepare-ubuntu-runner + - name: Generate Firebase options + uses: ./.github/actions/generate-firebase-options + with: + firebase_service_account_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }} + firebase_project_id: ${{ secrets.FIREBASE_PROJECT_ID }} + - name: Decode and save key.properties run: echo "${{ secrets.ANDROID_KEY_PROPERTIES }}" | base64 -d > ./android/key.properties @@ -57,6 +69,12 @@ jobs: - name: Prepare runner uses: ./.github/actions/prepare-macos-runner + - name: Generate Firebase options + uses: ./.github/actions/generate-firebase-options + with: + firebase_service_account_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }} + firebase_project_id: ${{ secrets.FIREBASE_PROJECT_ID }} + - name: Decode and save .env file run: echo "${{ secrets.ENV_FILE }}" | base64 -d > .env