eas build with gitignored google-services.json file.

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:27 (8 by maintainers)

github_iconTop GitHub Comments

27reactions
dsokalcommented, Jun 15, 2021

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"
5reactions
erquhartcommented, Jun 10, 2022

I have a related case - I use tailwind-rn for styles, so I constantly have unexpected changes to tailwind.css and tailwind.json in my commits, which results in merge conflicts with other PRs. Ignoring them and generating at build time works, but then eas also ignores them. So I started generating .easignore, too.

cc/ @diegoconcha as you mentioned having to keep two files up to date.

tl;dr: generate your .easignore from your .gitignore at build time.

Which (I think) is the only time you need it.

.gitignore:

node_modules/
.expo/
dist/

# ignore .easignore, too ✨
.easignore

### EASINCLUDE! ###
### BELOW THIS LINE WILL NOT BE IGNORED BY EAS ###

tailwind.css
tailwind.json

generate-easignore.js

const fs = require('fs')
const gitignore = fs.readFileSync('./.gitignore', 'utf8')
const easignore = gitignore.split('### EASINCLUDE! ###')[0]
fs.writeFileSync('./.easignore', easignore)

package.json

{
  "scripts": {
    "build": "node ./generate-easignore.js && eas build"
  }
}

This will output a .easignore that includes everything in .gitignore except the EASINCLUDE! line and everything below it. Use whatever you want for the separator string, I chose something that seemed programmatic so no one touches it unwittingly. Run it before you run eas build, probably in an npm script.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting build errors and crashes
A reference for troubleshooting build errors and crashes when using EAS Build.
Read more >
Should I add the google-services.json (from Firebase) to ...
My question is, should this .json file be added to a public (open source) repo. Is it something that should be secret, like...
Read more >
eas-cli
If you want to enforce the eas-cli version for your project, use the "cli.version" field in eas.json. Installing eas-cli to your project ...
Read more >
What to push to github? : r/androiddev
It's as simple as adding google-services.json on a newline in your .gitignore file. To also delete this file from your repository there are ......
Read more >
Configure Firebase project for Continuous Integration builds
Because you've added google-services.json to .gitignore , it will not exist in your Git remote repo. When new CI build triggered, it will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found