Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Automated Firebase Emulator Selection for Fastlane Builds #63

Merged
merged 5 commits into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions .github/workflows/xcodebuild-or-fastlane.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ on:
type: boolean
default: false
setupfirebaseemulator:
description: 'Setup the Firebase Emulator'
description: 'Setup the Firebase Emulator & automatically use it for the automated fastlane commands.'
required: false
type: boolean
default: false
firebaseemulatorimport:
description: 'Firebase import directory that contains Authentication, Cloud Firestore, Realtime Database and Cloud Storage data for Firebase emulators to use as a shareable, common baseline data set.'
required: false
type: string
default: ''
googleserviceinfoplistpath:
description: 'Path to the GoogleService-Info.plist file that is replaced using the content found in the secret GOOGLE_SERVICE_INFO_PLIST'
required: false
Expand Down Expand Up @@ -134,6 +139,9 @@ on:
GOOGLE_SERVICE_INFO_PLIST_BASE64:
description: 'The Base64 version of the GoogleService-Info.plist file that is used to replace the file found at googleserviceinfoplistpath if the arguemnt is set.'
required: false
GOOGLE_APPLICATION_CREDENTIALS_BASE64:
description: 'The Base64 version of the private key JSON file to boot up the firebase emulator to fully support the execution of cloud functions in the emulator. Only needed if cloud functions are used.'
required: false

jobs:
build_and_test:
Expand Down Expand Up @@ -367,12 +375,30 @@ jobs:
| xcpretty
- name: Fastlane
if: ${{ inputs.fastlanelane != '' }}
run: fastlane ${{ inputs.fastlanelane }}
run: |
if ${{ inputs.setupfirebaseemulator }}; then
# We try to do an npm install in the functions directory.
npm --prefix ./functions install || true

echo -n "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}" | base64 -d > "$RUNNER_TEMP/google-application-credentials.json"
export GOOGLE_APPLICATION_CREDENTIALS="$RUNNER_TEMP/google-application-credentials.json"
echo "Stored the Google application credentials at $GOOGLE_APPLICATION_CREDENTIALS"

if [ -n "${{ inputs.firebaseemulatorimport }}" ]; then
echo "Importing firebase emulator data from ${{ inputs.firebaseemulatorimport }}"
firebase emulators:exec --import=${{ inputs.firebaseemulatorimport }} 'fastlane ${{ inputs.fastlanelane }}'
else
firebase emulators:exec 'fastlane ${{ inputs.fastlanelane }}'
fi
else
fastlane ${{ inputs.fastlanelane }}
fi
env:
APP_STORE_CONNECT_API_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
APP_STORE_CONNECT_API_KEY_BASE64: ${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}
APPLE_ID: ${{ secrets.APPLE_ID }}
GOOGLE_APPLICATION_CREDENTIALS_BASE64: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}
- name: Perform CodeQL Analysis
if: ${{ !env.selfhosted && inputs.codeql }}
uses: github/codeql-action/analyze@v2
Expand All @@ -387,3 +413,7 @@ jobs:
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db || true
rm -rf ~/Library/MobileDevice/Provisioning\ Profiles || true
- name: Clean up Google application credentials
if: ${{ inputs.fastlanelane != '' || failure() }}
run: |
rm -rf $RUNNER_TEMP/google-application-credentials.json || true
Loading