Skip to content

Commit 6809fca

Browse files
authored
Merge pull request #533 from nimblehq/feature/#522-google-service-account-firebase
[#522] Replace Firebase Token with Google Service Account
2 parents a18a2ea + ce963ca commit 6809fca

File tree

8 files changed

+33
-13
lines changed

8 files changed

+33
-13
lines changed

.github/project_workflows/deploy_production_firebase.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Deploy Production Build To Firebase
33
# SECRETS needed:
44
### SSH_PRIVATE_KEY for Match Repo
55
### MATCH_PASS
6-
### FIREBASE_TOKEN
6+
### FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64
77

88
on:
99
push:
@@ -50,6 +50,13 @@ jobs:
5050
touch .env
5151
echo $ENV | base64 --decode > .env
5252
53+
- name: Read Google Service Account
54+
id: firebase_service_account
55+
uses: timheuer/[email protected]
56+
with:
57+
fileName: 'firebase_service_account.json'
58+
encodedString: ${{ secrets.FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}
59+
5360
- name: Bundle install
5461
run: bundle install
5562

@@ -80,7 +87,7 @@ jobs:
8087
- name: Build Production App and Distribute to Firebase
8188
run: bundle exec fastlane buildProductionAndUploadToFirebase
8289
env:
83-
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
90+
GOOGLE_APPLICATION_CREDENTIALS: ${{ steps.firebase_service_account.outputs.filePath }}
8491

8592
- name: Upload Artifacts
8693
uses: actions/upload-artifact@v3

.github/project_workflows/deploy_staging_firebase.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Deploy Staging Build To Firebase
33
# SECRETS needed:
44
### SSH_PRIVATE_KEY for Match Repo
55
### MATCH_PASS
6-
### FIREBASE_TOKEN
6+
### FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64
77

88
on:
99
push:
@@ -55,6 +55,13 @@ jobs:
5555
touch .env
5656
echo $ENV | base64 --decode > .env
5757
58+
- name: Read Google Service Account
59+
id: firebase_service_account
60+
uses: timheuer/[email protected]
61+
with:
62+
fileName: 'firebase_service_account.json'
63+
encodedString: ${{ secrets.FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}
64+
5865
- name: Bundle install
5966
# if: steps.bundleCache.outputs.cache-hit != 'true'
6067
run: bundle install
@@ -86,7 +93,7 @@ jobs:
8693
- name: Build App and Distribute to Firebase
8794
run: bundle exec fastlane buildStagingAndUploadToFirebase
8895
env:
89-
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
96+
GOOGLE_APPLICATION_CREDENTIALS: ${{ steps.firebase_service_account.outputs.filePath }}
9097

9198
- name: Upload Artifacts
9299
uses: actions/upload-artifact@v3

.github/wiki/CodeMagic.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Out of the box, the CodeMagic Template has the following workflows and steps:
3333
| MATCH_PASSWORD | The password is used to encrypt/decrypt the Match repository to store the distribution certificates and provisioning profiles. |
3434
| MATCH_SSH_KEY | The SSH private key is used for cloning the Match repository that contains your distribution certificates and provisioning. |
3535
| KEYCHAIN_PASSWORD | The password to access the keychain. |
36-
| FIREBASE_CLI_TOKEN | [Firebase token](https://firebase.google.com/docs/cli#cli-ci-systems) for uploading build to Firebase Distributions and Analytics. |
36+
| FIREBASE_SERVICE_ACCOUNT | [Google Service Firebase Account](https://firebase.google.com/docs/app-distribution/ios/distribute-fastlane#service-acc-fastlane) for uploading build to Firebase Distributions and Analytics. |
3737
| APPSTORE_CONNECT_API_KEY | [App Store Connect API](https://docs.fastlane.tools/actions/app_store_connect_api_key/) for uploading build to TestFlight or App Store. It should be `base64` encoded. |
3838
| API_KEY_ID | The key identifier of your App Store Connect API key. |
3939
| ISSUER_ID | The issuer of your App Store Connect API key. |
@@ -57,4 +57,4 @@ ROOT
5757
├──...
5858
```
5959

60-
4. Push changes to SCM.
60+
4. Push changes to SCM.

.github/wiki/Github-Actions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Make sure the following secrets are set up.
5353
|SSH_PRIVATE_KEY |SSH key connected to a user with access to the match repo for check out the match repo. |- ||||
5454
|MATCH_PASS |Fastlane Match Passphrase for decrypting a match repository. |- ||||
5555
|APPSTORE_CONNECT_API_KEY|App Store Connect API https://docs.fastlane.tools/actions/app_store_connect_api_key/ for uploading build to TestFlight or App Store. Should be `base64` encoded.|- |- |- ||
56-
|FIREBASE_TOKEN |Firebase token https://firebase.google.com/docs/cli#cli-ci-systems for uploading build to Firebase Distributions and Analytics. |- |||✅ For uploading dSYM to Crashlytics|
56+
|FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64|Google Service Firebase Account https://firebase.google.com/docs/app-distribution/ios/distribute-fastlane#service-acc-fastlane for uploading build to Firebase Distributions and Analytics. Should be `base64` encoded.|- |||✅ For uploading dSYM to Crashlytics|
5757

5858
## Installation
5959

@@ -63,4 +63,4 @@ Make sure the following secrets are set up.
6363
- fastlane/Constants/Constants.rb
6464
3. Get APPSTORE_CONNECT_API_KEY base64 from AuthKey file (.p8) with `cat AuthKey_ABCDEFGH.p8 | base64`.
6565
4. Provide SECRETS noted in `yml` file in [Github Project's Setting](https://docs.github.com/en/actions/reference/encrypted-secrets)
66-
4. Push changes to Github
66+
4. Push changes to Github

.github/workflows/test_upload_build_to_firebase.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Test Upload Build to Firebase
33
# SECRETS needed:
44
### SSH_PRIVATE_KEY for Match Repo
55
### MATCH_PASS
6-
### FIREBASE_TOKEN
6+
### FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64
77
### STAGING_FIREBASE_APP_ID
88
### TEAM_ID
99

@@ -34,6 +34,13 @@ jobs:
3434
yarn global add firebase-tools
3535
echo "$(yarn global bin)" >> $GITHUB_PATH
3636
37+
- name: Read Google Service Account
38+
id: firebase_service_account
39+
uses: timheuer/[email protected]
40+
with:
41+
fileName: 'firebase_service_account.json'
42+
encodedString: ${{ secrets.FIREBASE_GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}
43+
3744
- name: Bundle install
3845
run: bundle install
3946

@@ -67,7 +74,7 @@ jobs:
6774
- name: Build App and Distribute to Firebase
6875
run: bundle exec fastlane buildStagingAndUploadToFirebase
6976
env:
70-
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
77+
GOOGLE_APPLICATION_CREDENTIALS: ${{ steps.firebase_service_account.outputs.filePath }}
7178

7279
- name: Upload Artifacts
7380
uses: actions/upload-artifact@v3

codemagic.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ workflows:
77
- fastlane
88
xcode: latest
99
cocoapods: default
10+
firebase_service_account: $FIREBASE_SERVICE_ACCOUNT
1011
cache:
1112
cache_paths:
1213
- $HOME/Library/Caches/CocoaPods
@@ -71,6 +72,7 @@ workflows:
7172
- fastlane
7273
xcode: latest
7374
cocoapods: default
75+
firebase_service_account: $FIREBASE_SERVICE_ACCOUNT
7476
cache:
7577
cache_paths:
7678
- $HOME/Library/Caches/CocoaPods

fastlane/Constants/Secret.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ enum Secret {
1111

1212
static let keychainPassword = EnvironmentParser.string(key: "KEYCHAIN_PASSWORD")
1313

14-
static let firebaseCLIToken = EnvironmentParser.string(key: "FIREBASE_TOKEN")
15-
1614
static let appstoreConnectAPIKey = EnvironmentParser.string(key: "APPSTORE_CONNECT_API_KEY")
1715

1816
static let appStoreKeyIdKey = EnvironmentParser.string(key: "API_KEY_ID")

fastlane/Helpers/Distribution.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ enum Distribution {
2121
app: .userDefined(environment.firebaseAppId),
2222
groups: .userDefined(groups),
2323
releaseNotes: .userDefined(releaseNotes),
24-
firebaseCliToken: .userDefined(Secret.firebaseCLIToken),
2524
debug: .userDefined(true)
2625
)
2726
}

0 commit comments

Comments
 (0)