74
74
# Find the config associated to the firebase project in .firebaserc
75
75
gcloudProject=$(cat .firebaserc | jq -r --arg alias "$gitBranch" '.projects[$alias] // .projects.default')
76
76
77
+ # Set other app configs (settings within .firebaserc in the ci.setEnv section)
78
+ config=$(cat .firebaserc | jq -r --arg alias "$gitBranch" '.ci.setEnv[$alias] // .ci.setEnv.master')
79
+ echo "REACT_APP_FIREADMIN_ENV=$(echo $config | jq -r '.REACT_APP_FIREADMIN_ENV')" >> $GITHUB_ENV
80
+ echo "REACT_APP_SEGMENT_ID=$(echo $config | jq -r '.REACT_APP_SEGMENT_ID')" >> $GITHUB_ENV
81
+ echo "REACT_APP_SENTRY_DSN=$(echo $config | jq -r '.REACT_APP_SENTRY_DSN')" >> $GITHUB_ENV
82
+ echo "REACT_APP_PUBLIC_VAPID_KEY=$(echo $config | jq -r '.REACT_APP_PUBLIC_VAPID_KEY')" >> $GITHUB_ENV
83
+ echo "REACT_APP_ALGOLIA_APP_ID=$(echo $config | jq -r '.REACT_APP_ALGOLIA_APP_ID')" >> $GITHUB_ENV
84
+ echo "REACT_APP_ALGOLIA_API_KEY=$(echo $config | jq -r '.REACT_APP_ALGOLIA_API_KEY')" >> $GITHUB_ENV
85
+
77
86
echo Exporting Firebase SDK Config for $gcloudProject project...
78
87
79
88
# Use firebase SDK API to get the app's configuration (databaseURL is removed since it is set to the emulator URL)
@@ -82,23 +91,21 @@ jobs:
82
91
tr '\n' ' ' | \
83
92
sed 's/.*initializeApp(//g' | \
84
93
sed 's/);//g' | \
85
- jq -r 'del(.databaseURL) | to_entries[] | [.key, (.value | tojson)] | join("::")' | \
86
- sed 's/:"/:/g; s/^/echo \"::set-env name=REACT_APP_FIREBASE_/g' \
94
+ jq -r 'del(.databaseURL) | to_entries[] | [.key, (.value | tojson)] | join("=")' | \
95
+ sed 's/"//1' | \
96
+ sed 's/:"/:/g; s/^/echo \"REACT_APP_FIREBASE_/g' \
87
97
)
88
98
89
99
# Set emulator settings
90
- echo "::set-env name=REACT_APP_FIREBASE_DATABASE_EMULATOR_HOST::localhost:$(cat firebase.json | jq .emulators.database.port)"
91
- echo "::set-env name=REACT_APP_FIRESTORE_EMULATOR_HOST::localhost:$(cat firebase.json | jq .emulators.firestore.port)"
92
-
93
- # Set other app configs (settings within .firebaserc in the ci.setEnv section)
94
- $(yarn bin)/firebase-ci setEnv
100
+ echo "REACT_APP_FIREBASE_DATABASE_EMULATOR_HOST=localhost:$(cat firebase.json | jq .emulators.database.port)" >> $GITHUB_ENV
101
+ echo "REACT_APP_FIRESTORE_EMULATOR_HOST=localhost:$(cat firebase.json | jq .emulators.firestore.port)" >> $GITHUB_ENV
95
102
96
103
echo Begin evaluating project config to export as environment variables:
97
104
98
105
# Loop through each line of config and evaluate to export env vars
99
106
while IFS= read -r line; do
100
107
echo Evaluating: $line
101
- eval $line
108
+ eval $line >> $GITHUB_ENV
102
109
done <<< "$firebaseConfig"
103
110
104
111
- name : Print CI Env Variables
@@ -159,7 +166,6 @@ jobs:
159
166
key : ${{ runner.os }}-firebase-${{ steps.cache-settings.outputs.firebase-tools }}
160
167
161
168
- name : Set Test Environment Settings
162
- id : emulator-settings
163
169
env :
164
170
GITHUB_REF : ${{ github.ref }}
165
171
SKIP_CYPRESS_RECORDING : ${{ secrets.SKIP_CYPRESS_RECORDING }}
@@ -168,14 +174,14 @@ jobs:
168
174
gcloudProject=$(cat .firebaserc | jq -r --arg branch "$gitBranch" '.projects[$branch] // .projects.master')
169
175
170
176
echo "Exposing settings to environment for branch: $gitBranch and project: $gcloudProject..."
171
- echo "::set-env name= GCLOUD_PROJECT:: $gcloudProject"
172
- echo "::set-env name= FIREBASE_DATABASE_EMULATOR_HOST:: localhost:$(cat firebase.json | jq .emulators.database.port)"
173
- echo "::set-env name= FIRESTORE_EMULATOR_HOST:: localhost:$(cat firebase.json | jq .emulators.firestore.port)"
174
- echo "::set-env name= CYPRESS_BASE_URL:: http://localhost:$(cat package.json | jq .config.port)"
177
+ echo "GCLOUD_PROJECT= $gcloudProject" >> $GITHUB_ENV
178
+ echo "FIREBASE_DATABASE_EMULATOR_HOST= localhost:$(cat firebase.json | jq .emulators.database.port)" >> $GITHUB_ENV
179
+ echo "FIRESTORE_EMULATOR_HOST= localhost:$(cat firebase.json | jq .emulators.firestore.port)" >> $GITHUB_ENV
180
+ echo "CYPRESS_BASE_URL= http://localhost:$(cat package.json | jq .config.port)" >> $GITHUB_ENV
175
181
176
182
echo "Generating Service Account File..."
177
183
echo "$(echo $SERVICE_ACCOUNT | jq .)" > $HOME/serviceAccount.json
178
- echo "::set-env name= GOOGLE_APPLICATION_CREDENTIALS:: $HOME/serviceAccount.json"
184
+ echo "GOOGLE_APPLICATION_CREDENTIALS= $HOME/serviceAccount.json" >> $GITHUB_ENV
179
185
180
186
- name : Print CI Env Variables
181
187
run : |
0 commit comments