eas build with gitignored google-services.json file.
Hello, Great tool! enjoying using it a lot.
At the moment I am having to commit my google-services.json & GoogleService-Info.plist files in order to allow the cloud-build to work properly but this seems a bit of a security risk?
Ideally, I'd have these files reference in my .gitignore
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] [17:16:45] Cannot copy google-services.json from /usr/local/lib/node_modules/@expo/eas-build-worker/workingdir/build/google-services-staging.json to /usr/local/lib/node_modules/@expo/eas-build-worker/workingdir/build/android/app/google-services.json. Please make sure the source and destination paths exist.
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] [17:16:45] Error: Cannot copy google-services.json from /usr/local/lib/node_modules/@expo/eas-build-worker/workingdir/build/google-services-staging.json to /usr/local/lib/node_modules/@expo/eas-build-worker/workingdir/build/android/app/google-services.json. Please make sure the source and destination paths exist.
[stderr] at setGoogleServicesFile (/usr/local/lib/node_modules/@expo/eas-build-worker/node_modules/@expo/config-plugins/src/android/GoogleServices.ts:79:11)
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at runMicrotasks (<anonymous>)
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at processTicksAndRejections (internal/process/task_queues.js:93:5)
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at /usr/local/lib/node_modules/@expo/eas-build-worker/node_modules/@expo/config-plugins/src/android/GoogleServices.ts:53:7
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at action (/usr/local/lib/node_modules/@expo/eas-build-worker/node_modules/@expo/config-plugins/src/plugins/core-plugins.ts:118:23)
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at action (/usr/local/lib/node_modules/@expo/eas-build-worker/node_modules/@expo/config-plugins/src/plugins/compiler-plugins.ts:282:23)
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at evalModsAsync (/usr/local/lib/node_modules/@expo/eas-build-worker/node_modules/@expo/config-plugins/src/plugins/mod-compiler.ts:75:25)
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at compileModsAsync (/usr/local/lib/node_modules/@expo/eas-build-worker/node_modules/@expo/config-plugins/src/plugins/mod-compiler.ts:17:10)
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at configureManagedProjectAsync (/usr/local/lib/node_modules/@expo/eas-build-worker/node_modules/expo-cli/src/commands/apply/configureProjectAsync.ts:115:12)
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at prebuildAsync (/usr/local/lib/node_modules/@expo/eas-build-worker/node_modules/expo-cli/src/commands/eject/Eject.ts:146:25)
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at Object.ejectAsync (/usr/local/lib/node_modules/@expo/eas-build-worker/node_modules/expo-cli/src/commands/eject/Eject.ts:78:19)
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at actionAsync (/usr/local/lib/node_modules/@expo/eas-build-worker/node_modules/expo-cli/src/commands/eject.ts:46:5)
Sat, 06 Feb 2021 17:16:45 GMT
[stderr] at Command.<anonymous> (/usr/local/lib/node_modules/@expo/eas-build-worker/node_modules/expo-cli/src/exp.ts:346:7)
Sat, 06 Feb 2021 17:16:45 GMT
Build failed: node exited with non-zero code: 1
Is there any workaround to this scenario/issue?
Thank you!
It'd be nice to extend eas credentials to storing secrets in general. That way eas submit could get the Google api key file and the EXPO_APPLE_APP_SPECIFIC_PASSWORD from the Expo server.
I have a similar issue, I'm using aws amplify which downloads a file aws-exports.js which is in .gitignore (as it should be). I need to include it in build without editing .gitignore.
Hi guys,
You don't need to commit the gitignored files to the repo.
Here's a workaround (assuming you want your build to have access to google-service.json):
- Convert the secret file to a base64-encoded string:
$ base64 google-services.json - Copy the output of the command and set an EAS secret with
eas secret:create(e.g.GOOGLE_SERVICES_BASE64) - Use an EAS Build hook (https://docs.expo.io/build-reference/how-tos/#eas-build-specific-npm-hooks) to restore the file:
In package.json:
"eas-build-pre-install": "echo $GOOGLE_SERVICES_BASE64 | base64 --decode > /path/to/google-services.json"
@dsokal is this still the recommended way to handle this situation? I'm using amplify and also have the aws-exports.js file someone else mentioned above. This file changes based on changes we make to the backend so it's somewhat dynamic so we'd need to update it's eas secret value often. I would much rather prefer to be able to include the latest version of this file in the build vs it being ignored by eas because it's in the .gitignore. Thank you!
Hey @diegoconcha, Yes, this is still the recommended way of handling this case. I agree this is not the most convenient way of working with Amplify. I'll open another issue to remember about this.
@diegoconcha If you are using default git workflow (you don't have requireCommit: true in eas.json) then you can add .easignore file
Note that if easignore is present, gitingore files are not respected(even in subdirectories) and there can only be one .easignore and it has to be in the root of the repository
@diegoconcha If you are using default git workflow (you don't have
requireCommit: truein eas.json) then you can add.easignorefileNote that if easignore is present, gitingore files are not respected(even in subdirectories) and there can only be one
.easignoreand it has to be in the root of the repository
Thanks @wkozyra95 for your reply. The challenge with this approach is now we have to keep two ignore files up-to-date (.gitignore and .easignore). This approach is definitely an improvement over the base64 encoded string and eas pre-install step discussed above but it would probably be easier for most teams if expo added a .easincludes file where we can include important cloud configuration files like the aws-exports.js in our case. I hope you all consider adding this in the near future.
@diegoconcha If you are using default git workflow (you don't have
requireCommit: truein eas.json) then you can add.easignorefile Note that if easignore is present, gitingore files are not respected(even in subdirectories) and there can only be one.easignoreand it has to be in the root of the repositoryThanks @wkozyra95 for your reply. The challenge with this approach is now we have to keep two ignore files up-to-date (
.gitignoreand.easignore). This approach is definitely an improvement over the base64 encoded string and eas pre-install step discussed above but it would probably be easier for most teams if expo added a.easincludesfile where we can include important cloud configuration files like theaws-exports.jsin our case. I hope you all consider adding this in the near future.
Hi @diegoconcha or @everyone here! I am currently on the process of eas build-ing an app, and I was wondering whether to use the base64 route or this .easignore. I am leaning towards the latter, but I am worried about inadvertently exposing my aws-exports.js to prying eyes. What are your thoughts about this?
If it's a secret it should be passed via EAS Secrets (base64 route), but if I understand correctly aws-exports.js is part of the js bundle, so anyone can extract those values by unzipping apk/ipa, so there is no point in going to far in protecting any secrets that are available client-side.
@diegoconcha If you are using default git workflow (you don't have
requireCommit: truein eas.json) then you can add.easignorefile Note that if easignore is present, gitingore files are not respected(even in subdirectories) and there can only be one.easignoreand it has to be in the root of the repositoryThanks @wkozyra95 for your reply. The challenge with this approach is now we have to keep two ignore files up-to-date (
.gitignoreand.easignore). This approach is definitely an improvement over the base64 encoded string and eas pre-install step discussed above but it would probably be easier for most teams if expo added a.easincludesfile where we can include important cloud configuration files like theaws-exports.jsin our case. I hope you all consider adding this in the near future.Hi @diegoconcha or @everyone here! I am currently on the process of
eas build-ing an app, and I was wondering whether to use the base64 route or this.easignore. I am leaning towards the latter, but I am worried about inadvertently exposing myaws-exports.jsto prying eyes. What are your thoughts about this?
Hey @AllanBengco we went the .easignore route. Ours is a copy of our .gitignore without the aws-exports.js so that the aws-exports.js is included in the build. This file only has routes and high level config of our backend so mostly stuff that's already easy to figure out by analyzing network traffic on the device or using our app. Essentially nothing we're worried about exposing but take a detailed look yourself.
Like @wkozyra95 said, the aws-exports.js is part of the js bundle after the app is built. As a result, it can also be replaced via an OTA update (eas update or expo updates). We updated our app via eas update and accidentally pointed our prod users to our dev backend for a short period of time so heads up @AllanBengco.
@diegoconcha If you are using default git workflow (you don't have
requireCommit: truein eas.json) then you can add.easignorefile Note that if easignore is present, gitingore files are not respected(even in subdirectories) and there can only be one.easignoreand it has to be in the root of the repositoryThanks @wkozyra95 for your reply. The challenge with this approach is now we have to keep two ignore files up-to-date (
.gitignoreand.easignore). This approach is definitely an improvement over the base64 encoded string and eas pre-install step discussed above but it would probably be easier for most teams if expo added a.easincludesfile where we can include important cloud configuration files like theaws-exports.jsin our case. I hope you all consider adding this in the near future.Hi @diegoconcha or @everyone here! I am currently on the process of
eas build-ing an app, and I was wondering whether to use the base64 route or this.easignore. I am leaning towards the latter, but I am worried about inadvertently exposing myaws-exports.jsto prying eyes. What are your thoughts about this?Hey @AllanBengco we went the .easignore route. Ours is a copy of our .gitignore without the aws-exports.js so that the aws-exports.js is included in the build. This file only has routes and high level config of our backend so mostly stuff that's already easy to figure out by analyzing network traffic on the device or using our app. Essentially nothing we're worried about exposing but take a detailed look yourself.
Like @wkozyra95 said, the aws-exports.js is part of the js bundle after the app is built. As a result, it can also be replaced via an OTA update (eas update or expo updates). We updated our app via eas update and accidentally pointed our prod users to our dev backend for a short period of time so heads up @AllanBengco.
Thank you @diegoconcha for your inputs!
I experimented with the base64 route, and was able to build my app successfully. Based on your comment, I realized that the one good thing about encoding aws-exports is that I do not have to always remember to strictly follow git checkout prod and amplify env checkout prod, before eas build. Even if I accidentally build what is in the dev branch, the encoded aws-exports remains unchanged in EAS Secrets, reducing the likelihood of accidents similar to what you described.
@diegoconcha If you are using default git workflow (you don't have
requireCommit: truein eas.json) then you can add.easignorefile Note that if easignore is present, gitingore files are not respected(even in subdirectories) and there can only be one.easignoreand it has to be in the root of the repositoryThanks @wkozyra95 for your reply. The challenge with this approach is now we have to keep two ignore files up-to-date (
.gitignoreand.easignore). This approach is definitely an improvement over the base64 encoded string and eas pre-install step discussed above but it would probably be easier for most teams if expo added a.easincludesfile where we can include important cloud configuration files like theaws-exports.jsin our case. I hope you all consider adding this in the near future.Hi @diegoconcha or @everyone here! I am currently on the process of
eas build-ing an app, and I was wondering whether to use the base64 route or this.easignore. I am leaning towards the latter, but I am worried about inadvertently exposing myaws-exports.jsto prying eyes. What are your thoughts about this?Hey @AllanBengco we went the .easignore route. Ours is a copy of our .gitignore without the aws-exports.js so that the aws-exports.js is included in the build. This file only has routes and high level config of our backend so mostly stuff that's already easy to figure out by analyzing network traffic on the device or using our app. Essentially nothing we're worried about exposing but take a detailed look yourself. Like @wkozyra95 said, the aws-exports.js is part of the js bundle after the app is built. As a result, it can also be replaced via an OTA update (eas update or expo updates). We updated our app via eas update and accidentally pointed our prod users to our dev backend for a short period of time so heads up @AllanBengco.
Thank you @diegoconcha for your inputs!
I experimented with the base64 route, and was able to build my app successfully. Based on your comment, I realized that the one good thing about encoding
aws-exportsis that I do not have to always remember to strictly followgit checkout prodandamplify env checkout prod, beforeeas build. Even if I accidentally build what is in thedevbranch, the encodedaws-exportsremains unchanged in EAS Secrets, reducing the likelihood of accidents similar to what you described.
@AllanBengco when the app is built, the base64 method creates the aws-exports.js file so you still have the same issue if you do an expo or eas update since the file is still created and part of the js bundle. EAS Secrets is really only protecting build-time secrets and it isn't used at run-time which is when the aws-exports.js is used and where it can be modified by doing an over-the-air update. By using the base64 + EAS Secrets approach now you have to remember to update the secret if anything on your amplify backend changes like the userpool id. So you're adding an extra step but don't have the protection you think you have.
@diegoconcha If you are using default git workflow (you don't have
requireCommit: truein eas.json) then you can add.easignorefile Note that if easignore is present, gitingore files are not respected(even in subdirectories) and there can only be one.easignoreand it has to be in the root of the repositoryThanks @wkozyra95 for your reply. The challenge with this approach is now we have to keep two ignore files up-to-date (
.gitignoreand.easignore). This approach is definitely an improvement over the base64 encoded string and eas pre-install step discussed above but it would probably be easier for most teams if expo added a.easincludesfile where we can include important cloud configuration files like theaws-exports.jsin our case. I hope you all consider adding this in the near future.Hi @diegoconcha or @everyone here! I am currently on the process of
eas build-ing an app, and I was wondering whether to use the base64 route or this.easignore. I am leaning towards the latter, but I am worried about inadvertently exposing myaws-exports.jsto prying eyes. What are your thoughts about this?Hey @AllanBengco we went the .easignore route. Ours is a copy of our .gitignore without the aws-exports.js so that the aws-exports.js is included in the build. This file only has routes and high level config of our backend so mostly stuff that's already easy to figure out by analyzing network traffic on the device or using our app. Essentially nothing we're worried about exposing but take a detailed look yourself. Like @wkozyra95 said, the aws-exports.js is part of the js bundle after the app is built. As a result, it can also be replaced via an OTA update (eas update or expo updates). We updated our app via eas update and accidentally pointed our prod users to our dev backend for a short period of time so heads up @AllanBengco.
Thank you @diegoconcha for your inputs! I experimented with the base64 route, and was able to build my app successfully. Based on your comment, I realized that the one good thing about encoding
aws-exportsis that I do not have to always remember to strictly followgit checkout prodandamplify env checkout prod, beforeeas build. Even if I accidentally build what is in thedevbranch, the encodedaws-exportsremains unchanged in EAS Secrets, reducing the likelihood of accidents similar to what you described.@AllanBengco when the app is built the base64 method creates the file so you still have the same issue if you do an expo or eas update since the file is still created. Secrets is really only protecting build-time secrets it doesn't get used at run-time which is when the aws-exports.js is used and where it can be modified by doing an over-the-air update.
What I did was to manually create the base64 file and save this in Secrets. Then, add a pre-build script so that what is stored in Secrets is decoded and saved as aws-exports.js
$base64 aws-exports.js- Copy the output
- In Expo.dev, add
AWS_EXPORTSto Secrets and paste the value from the output - Add
"eas-build-pre-install": "echo $AWS_EXPORTS | base64 --decode > ./src/aws-exports.js"topackage.jsonscripts.
I was under the impression that this would basically decode what is already in the Secrets and save it as aws-exports.js for building. I will experiment on this later and try to purposely use dev environment, then build.
@diegoconcha If you are using default git workflow (you don't have
requireCommit: truein eas.json) then you can add.easignorefile Note that if easignore is present, gitingore files are not respected(even in subdirectories) and there can only be one.easignoreand it has to be in the root of the repositoryThanks @wkozyra95 for your reply. The challenge with this approach is now we have to keep two ignore files up-to-date (
.gitignoreand.easignore). This approach is definitely an improvement over the base64 encoded string and eas pre-install step discussed above but it would probably be easier for most teams if expo added a.easincludesfile where we can include important cloud configuration files like theaws-exports.jsin our case. I hope you all consider adding this in the near future.Hi @diegoconcha or @everyone here! I am currently on the process of
eas build-ing an app, and I was wondering whether to use the base64 route or this.easignore. I am leaning towards the latter, but I am worried about inadvertently exposing myaws-exports.jsto prying eyes. What are your thoughts about this?Hey @AllanBengco we went the .easignore route. Ours is a copy of our .gitignore without the aws-exports.js so that the aws-exports.js is included in the build. This file only has routes and high level config of our backend so mostly stuff that's already easy to figure out by analyzing network traffic on the device or using our app. Essentially nothing we're worried about exposing but take a detailed look yourself. Like @wkozyra95 said, the aws-exports.js is part of the js bundle after the app is built. As a result, it can also be replaced via an OTA update (eas update or expo updates). We updated our app via eas update and accidentally pointed our prod users to our dev backend for a short period of time so heads up @AllanBengco.
Thank you @diegoconcha for your inputs! I experimented with the base64 route, and was able to build my app successfully. Based on your comment, I realized that the one good thing about encoding
aws-exportsis that I do not have to always remember to strictly followgit checkout prodandamplify env checkout prod, beforeeas build. Even if I accidentally build what is in thedevbranch, the encodedaws-exportsremains unchanged in EAS Secrets, reducing the likelihood of accidents similar to what you described.@AllanBengco when the app is built the base64 method creates the file so you still have the same issue if you do an expo or eas update since the file is still created. Secrets is really only protecting build-time secrets it doesn't get used at run-time which is when the aws-exports.js is used and where it can be modified by doing an over-the-air update.
What I did was to manually create the base64 file and save this in Secrets. Then, add a pre-build script so that what is stored in Secrets is decoded and saved as
aws-exports.js
$base64 aws-exports.js- Copy the output
- In Expo.dev, add
AWS_EXPORTSto Secrets and paste the value from the output- Add
"eas-build-pre-install": "echo $AWS_EXPORTS | base64 --decode > ./src/aws-exports.js"topackage.jsonscripts.I was under the impression that this would basically decode what is already in the Secrets and save it as
aws-exports.jsfor building. I will experiment on this later and try to purposely usedevenvironment, then build.
You're correct but you are missing my point. As part of the build process, the aws-exports.js gets created and is present in the built bundle. More precisely it lives in the JS bundle which can be overwritten by an OTA update (this is the magic of OTA updates replacing the JS bundle). If you don't do or plan to do OTA updates then you're fine but most people using expo do OTA updates to get hot fixes out quickly without waiting for app store approval in which case you can accidentally overwrite the aws-exports.js that was built from the secret with whatever you have locally when you create the OTA update.
Hi guys,
You don't need to commit the gitignored files to the repo.
Here's a workaround (assuming you want your build to have access to google-service.json):
- Convert the secret file to a base64-encoded string:
$ base64 google-services.json- Copy the output of the command and set an EAS secret with
eas secret:create(e.g.GOOGLE_SERVICES_BASE64)- Use an EAS Build hook (https://docs.expo.io/build-reference/how-tos/#eas-build-specific-npm-hooks) to restore the file: In package.json:
"eas-build-pre-install": "echo $GOOGLE_SERVICES_BASE64 | base64 --decode > /path/to/google-services.json"
I Don't know if this is expected behavior but if I have my app.json file like this, expecting google services files in the root directory, for some reason EAS doesn't care and keeps searching them in the ios / android subdirectories.
app.json
{
"expo": {
"name": "Ping for Gitlab",
"owner": "zaniluca",
"slug": "ping4gitlab",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"bundleIdentifier": "con.zaniluca.ping4gitlab",
"googleServicesFile": "./GoogleService-Info.plist",
"supportsTablet": false
},
"android": {
"googleServicesFile": "./google-services.json",
"package": "con.zaniluca.ping4gitlab",
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
}
},
"plugins": ["@react-native-firebase/app"]
}
}
EAS Error message when building ios
› Copying ios/PingforGitlab/Supporting/Expo.plist ➜ ./Expo.plist
› Compiling PingforGitlab » SplashScreen.storyboard
› Copying ios/PingforGitlab/GoogleService-Info.plist ➜ ./GoogleService-Info.plist
❌ error: Build input file cannot be found: '/Users/expo/workingdir/build/ios/PingforGitlab/GoogleService-Info.plist' (in target 'PingforGitlab' from project 'PingforGitlab')
The solution I adopted is this:
echo $GOOGLE_SERVICES_ANDROID_BASE64 | base64 --decode > ./android/app/google-services.json && echo $GOOGLE_SERVICES_IOS_BASE64 | base64 --decode > ios/PingforGitlab/GoogleService-Info.plist
Is there anything that I'm doing wrong
@ZaniLuca app.json values that configure native code are ignored if you are ejected. I checked your last few builds and they are all bare workflow, if ejecting was not intentional you can just delete or gitiingore android and ios directories
@ZaniLuca app.json values that configure native code are ignored if you are ejected. I checked your last few builds and they are all bare workflow, if ejecting was not intentional you can just delete or gitiingore android and ios directories
Oh really? I'm using a custom development client, I didn't know it was the same as ejecting. Thanks for pointing it out😅
I'm using a custom development client, I didn't know it was the same as ejecting.
It's not the same, you can use a custom dev client without ejecting. Most likely you ejected by running expo run:ios/android or expo prebuild
I'm using a custom development client, I didn't know it was the same as ejecting.
It's not the same, you can use a custom dev client without ejecting. Most likely you ejected by running
expo run:ios/androidorexpo prebuild
Yea I had to run expo prebuild as stated in the react-native-firebase docs thanks
I've tried following both versions of how to upload the secrets and am still getting errors, and am wondering if anyone has succeeded in fixing them, or could provide some extra help.
When trying the .easignore version I created a base level .easignore and set its contents to the same as my .gitignore, but with the aws-exports and google services files negated as below
!aws-exports.js
!google-services.json
This didn't fix the original issue or change anything at all in the built, and gave the same results as not doing this, getting
File specified via "android.googleServicesFile" field in your app.json is not checked in to your repository and won't be uploaded to the builder.
Use EAS Secret to pass all values that you don't want to include in your version control. Learn more: https://docs.expo.dev/build-reference/variables/#using-secrets-in-environment-variables
If you are using that file for compatibility with the classic build service (expo build) you can silence this warning by setting your build profile's env.GOOGLE_SERVICES_FILE in eas.json to any non-empty string.
then, during the gradlew and fastline build processes in android and iOS respectively
❌ Metro encountered an error:
Unable to resolve module ./src/aws-exports from /Users/expo/workingdir/build/index.js:
None of these files exist:
* src/aws-exports(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
So I moved onto the secrets route
After base64'ing my aws-exports and google-services.json, creating eas secrets from them named GOOGLE_SERVICES and AWS_EXPORTS with that output via eas secret:create, then adding the following pre-install script in package.json
"eas-build-pre-install": "echo $GOOGLE_SERVICES | base64 --decode > ./google-services.json && echo $AWS_EXPORTS | base64 --decode > ./src/aws-exports.json"
I am now getting this error in both the Xcode Logs for iOS, and in the gradlew logs for Android
error src/aws-exports.json: Unexpected token: keyword (const) in file src/aws-exports.json at 5:0.
Seems to me like it now recognizes that the files exist, but isn't able to read from them and I am unsure as to why. Obviously const is a valid kwarg in js, and the first thing appearing in aws-exports.
I would love any direction on how to fix if anyone has suggestions, thanks in advance!