Fastlane - Get automatically app key from google-services.json
All Android application that included Firebase have mandatory this file : google-services.json
When we want automatize delivery with fastlane on Firebase, we need to provide many informations on the lane such like "app", "servicecredentialsfile",...
In fact, many Android projects has one or more build flavors and the delivery can be harder with the configuration on which target we want to deploy.
We need to store many sensitive informations like key on the env file.
We not push this file on the repository and it's not a good practice to have them has CI variables.
The purpose of this feature request is to automatize the retrieve of app key from google-services.json.
For this, we just need few informations on env / CI file :
- location of google-services.json (that can be split in an other feature) *1;
- package name declared on env / CI file.
Only with your package name, you can retrieve (or not) your app key from google-services.json.
This is a snippet of code for make this one :
Parse the JSON content
jsondata = JSON.parse(filecontent)
Search for the appid corresponding to the packagename
appid = ""
jsondata["client"].each do |client|
if client["clientinfo"]["androidclientinfo"]["package_name"] == targetpackagename
appid = client["clientinfo"]["mobilesdkapp_id"]
break
end
end