From f947b41f24c91484b116065b5869a9abed341438 Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Thu, 19 Dec 2024 22:43:26 +0100 Subject: [PATCH] fix google map secrets --- frontend/.github/workflows/build_app_ios.yaml | 8 +++++--- frontend/README.md | 5 ++--- frontend/ios/Runner/AppDelegate.swift | 3 +-- frontend/ios/fastlane/.env.sample | 2 +- frontend/ios/fastlane/Fastfile | 12 +++++++++++- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/frontend/.github/workflows/build_app_ios.yaml b/frontend/.github/workflows/build_app_ios.yaml index 1e3bbf5..15e63c7 100644 --- a/frontend/.github/workflows/build_app_ios.yaml +++ b/frontend/.github/workflows/build_app_ios.yaml @@ -40,14 +40,15 @@ jobs: MATCH_REPO_SSH_KEY: ${{ secrets.IOS_MATCH_REPO_SSH_KEY_BASE64 }} - name: Install fastlane - run: bundle install && bundle update + run: bundle install working-directory: ios - - name: Install dependencies + - name: Install dependencies and clean up run: | flutter pub get bundle exec pod install - bundle exec pod update + flutter clean + bundle exec pod cache clean --all working-directory: ios - name: Run fastlane lane @@ -61,3 +62,4 @@ jobs: IOS_ASC_ISSUER_ID: ${{ secrets.IOS_ASC_ISSUER_ID }} IOS_ASC_KEY: ${{ secrets.IOS_ASC_KEY }} MATCH_PASSWORD: ${{ secrets.IOS_MATCH_PASSWORD }} + IOS_GOOGLE_MAPS_API_KEY: ${{ secrets.IOS_GOOGLE_MAPS_API_KEY }} diff --git a/frontend/README.md b/frontend/README.md index 954d60d..740cf1e 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -50,13 +50,12 @@ Secrets used by fastlane are stored on hashicorp vault and are fetched by the CI ## Secrets These are mostly used by the CI/CD pipeline to deploy the application. The main usage for github actions is documented under [https://github.com/hashicorp/vault-action](https://github.com/hashicorp/vault-action). -**Global secrets** are used for both versions of the app (android and ios). -- `GOOGLE_MAPS_API_KEY` is used to authenticate with the Google Maps API **Platform-specific secrets** are used by the CI/CD pipeline to deploy to the respective app stores. +- `GOOGLE_MAPS_API_KEY` is used to authenticate with the Google Maps API and is scoped to the android platform - `ANDROID_KEYSTORE` is used to sign the android apk - `ANDROID_GOOGLE_KEY` is used to authenticate with the Google Play Store api -- `IOS_GOOGLE_...` +- `IOS_GOOGLE_MAPS_API_KEY` is used to authenticate with the Google Maps API and is scoped to the ios platform - `IOS_GOOGLE_...` - `IOS_GOOGLE_...` - `IOS_GOOGLE_...` \ No newline at end of file diff --git a/frontend/ios/Runner/AppDelegate.swift b/frontend/ios/Runner/AppDelegate.swift index 675b021..c3ad1bb 100644 --- a/frontend/ios/Runner/AppDelegate.swift +++ b/frontend/ios/Runner/AppDelegate.swift @@ -9,8 +9,7 @@ import GoogleMaps didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { // load the key from env - let key = ProcessInfo.processInfo.environment["GOOGLE_MAPS_API_KEY"]! - GMSServices.provideAPIKey(key) + GMSServices.provideAPIKey("IOS_GOOGLE_MAPS_API_KEY") GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/frontend/ios/fastlane/.env.sample b/frontend/ios/fastlane/.env.sample index 82595b4..e23af2b 100644 --- a/frontend/ios/fastlane/.env.sample +++ b/frontend/ios/fastlane/.env.sample @@ -10,4 +10,4 @@ IOS_ASC_ISSUER_ID="sample" SIGNING_KEY_FILE_PATH="sample" SIGNING_KEY_PASSWORD="sample" -GOOGLE_MAPS_API_KEY="sample" +IOS_GOOGLE_MAPS_API_KEY="sample" diff --git a/frontend/ios/fastlane/Fastfile b/frontend/ios/fastlane/Fastfile index d7a0c53..6be2c9d 100644 --- a/frontend/ios/fastlane/Fastfile +++ b/frontend/ios/fastlane/Fastfile @@ -33,7 +33,7 @@ platform :ios do "flutter", "build", "ipa", - "--release", + "--debug", "--build-name=#{build_name}", "--build-number=#{build_number}", ) @@ -64,6 +64,16 @@ platform :ios do readonly: true, ) + # replace secrets by real values, the stupid way + sh( + "sed", + "-i", + "", + "s/IOS_GOOGLE_MAPS_API_KEY/#{ENV["IOS_GOOGLE_MAPS_API_KEY"]}/g", + "ios/Runner/AppDelegate.swift" + + ) + sh( "flutter", "build",