From 35f10af2a8f5751d0b50265df0e1bbf57c19552c Mon Sep 17 00:00:00 2001 From: Bram De Coninck Date: Mon, 23 Dec 2024 16:48:57 +0100 Subject: [PATCH] Generate Firebase options in CICD --- .../generate-firebase-options/action.yaml | 34 +++++++++++++++++++ .github/workflows/default-workflow.yaml | 18 ++++++++++ .github/workflows/release-workflow.yaml | 18 ++++++++++ 3 files changed, 70 insertions(+) create mode 100644 .github/actions/generate-firebase-options/action.yaml diff --git a/.github/actions/generate-firebase-options/action.yaml b/.github/actions/generate-firebase-options/action.yaml new file mode 100644 index 0000000..c09d1e8 --- /dev/null +++ b/.github/actions/generate-firebase-options/action.yaml @@ -0,0 +1,34 @@ +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: Setup Firebase CLI + shell: bash + run: | + npm install -g firebase-tools + + - name: Firebase Login + shell: bash + run: | + echo "${{ inputs.firebase_service_account_json }}" | firebase login:ci --non-interactive + + - 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: firebase logout \ 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