Skip to content

Commit

Permalink
Generate Firebase options in CICD
Browse files Browse the repository at this point in the history
  • Loading branch information
BramDC3 committed Dec 23, 2024
1 parent 52118ed commit e24079b
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/actions/generate-firebase-options/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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: Configure Firebase Credentials
shell: bash
run: |
echo "${{ inputs.firebase_service_account_json }}" > service_account.json
[[ -f "service_account.json" ]] && echo "service_account.json exists!" || (echo "ERROR: service_account.json does NOT exist!"; exit 1)
export GOOGLE_APPLICATION_CREDENTIALS=service_account.json
- name: Generate Options File
shell: bash
env:
GOOGLE_APPLICATION_CREDENTIALS: service_account.json
run: |
[[ -f "service_account.json" ]] && echo "service_account.json exists!" || (echo "ERROR: service_account.json does NOT exist!"; exit 1)
[[ -z "$GOOGLE_APPLICATION_CREDENTIALS" ]] && (echo "ERROR: GOOGLE_APPLICATION_CREDENTIALS is NOT set!" && exit 1) || echo "GOOGLE_APPLICATION_CREDENTIALS is set: $GOOGLE_APPLICATION_CREDENTIALS"
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
18 changes: 18 additions & 0 deletions .github/workflows/default-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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

Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/release-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit e24079b

Please sign in to comment.