Skip to content

Commit acb428b

Browse files
authored
fix(ci): remove usage of set-env in CI workflows (#343)
1 parent ef6a6d2 commit acb428b

File tree

6 files changed

+46
-32
lines changed

6 files changed

+46
-32
lines changed

.github/workflows/app-deploy.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,20 @@ jobs:
7777
run: |
7878
set -o pipefail
7979
80-
# Set other app configs (settings within .firebaserc in the ci.setEnv section)
81-
$(yarn bin)/firebase-ci setEnv
82-
80+
8381
# Find the config associated to the firebase project in .firebaserc
8482
gitBranch=${GITHUB_REF##*/}
8583
gcloudProject=$(cat .firebaserc | jq -r --arg alias "$gitBranch" '.projects[$alias]')
8684
85+
# Set other app configs (settings within .firebaserc in the ci.setEnv section)
86+
config=$(cat .firebaserc | jq -r --arg alias "$gitBranch" '.ci.setEnv[$alias]')
87+
echo "REACT_APP_FIREADMIN_ENV=$(echo $config | jq -r '.REACT_APP_FIREADMIN_ENV')" >> $GITHUB_ENV
88+
echo "REACT_APP_SEGMENT_ID=$(echo $config | jq -r '.REACT_APP_SEGMENT_ID')" >> $GITHUB_ENV
89+
echo "REACT_APP_SENTRY_DSN=$(echo $config | jq -r '.REACT_APP_SENTRY_DSN')" >> $GITHUB_ENV
90+
echo "REACT_APP_PUBLIC_VAPID_KEY=$(echo $config | jq -r '.REACT_APP_PUBLIC_VAPID_KEY')" >> $GITHUB_ENV
91+
echo "REACT_APP_ALGOLIA_APP_ID=$(echo $config | jq -r '.REACT_APP_ALGOLIA_APP_ID')" >> $GITHUB_ENV
92+
echo "REACT_APP_ALGOLIA_API_KEY=$(echo $config | jq -r '.REACT_APP_ALGOLIA_API_KEY')" >> $GITHUB_ENV
93+
8794
echo Exporting Firebase SDK Config for $gcloudProject project...
8895
8996
# Use firebase SDK API to get the app's configuration (databaseURL is removed since it is set to the emulator URL above)
@@ -92,16 +99,17 @@ jobs:
9299
tr '\n' ' ' | \
93100
sed 's/.*initializeApp(//g' | \
94101
sed 's/);//g' | \
95-
jq -r 'to_entries[] | [.key, (.value | tojson)] | join("::")' | \
96-
sed 's/:"/:/g; s/^/echo \"::set-env name=REACT_APP_FIREBASE_/g' \
102+
jq -r 'to_entries[] | [.key, (.value | tojson)] | join("=")' | \
103+
sed 's/"//1' | \
104+
sed 's/:"/:/g; s/^/echo \"REACT_APP_FIREBASE_/g' \
97105
)
98106
99107
echo Begin evaluating project config to export as environment variables:
100108
101109
# Loop through each line of config and evaluate to export env vars
102110
while IFS= read -r line; do
103111
echo Evaluating: $line
104-
eval $line
112+
eval $line >> $GITHUB_ENV
105113
done <<< "$firebaseConfig"
106114
107115
- name: Verify App
@@ -137,7 +145,7 @@ jobs:
137145
packageName=$(cat package.json | jq -r '.name')
138146
packageVersion=$(cat package.json | jq -r '.version')
139147
gcloudProject=$(cat .firebaserc | jq -r --arg alias "$gitBranch" '.projects[$alias] // .projects.default')
140-
echo "::set-env name=PACKAGE_VERSION::$packageVersion"
148+
echo "PACKAGE_VERSION=localhost:$packageVersion" >> $GITHUB_ENV
141149
142150
echo Updating DB path \"/versionInfo/current\" value to version \"$packageVersion\"
143151

.github/workflows/app-verify.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ jobs:
7474
# Find the config associated to the firebase project in .firebaserc
7575
gcloudProject=$(cat .firebaserc | jq -r --arg alias "$gitBranch" '.projects[$alias] // .projects.default')
7676
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+
7786
echo Exporting Firebase SDK Config for $gcloudProject project...
7887
7988
# 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:
8291
tr '\n' ' ' | \
8392
sed 's/.*initializeApp(//g' | \
8493
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' \
8797
)
8898
8999
# 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
95102
96103
echo Begin evaluating project config to export as environment variables:
97104
98105
# Loop through each line of config and evaluate to export env vars
99106
while IFS= read -r line; do
100107
echo Evaluating: $line
101-
eval $line
108+
eval $line >> $GITHUB_ENV
102109
done <<< "$firebaseConfig"
103110
104111
- name: Print CI Env Variables
@@ -159,7 +166,6 @@ jobs:
159166
key: ${{ runner.os }}-firebase-${{ steps.cache-settings.outputs.firebase-tools }}
160167

161168
- name: Set Test Environment Settings
162-
id: emulator-settings
163169
env:
164170
GITHUB_REF: ${{ github.ref }}
165171
SKIP_CYPRESS_RECORDING: ${{ secrets.SKIP_CYPRESS_RECORDING }}
@@ -168,14 +174,14 @@ jobs:
168174
gcloudProject=$(cat .firebaserc | jq -r --arg branch "$gitBranch" '.projects[$branch] // .projects.master')
169175
170176
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
175181
176182
echo "Generating Service Account File..."
177183
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
179185
180186
- name: Print CI Env Variables
181187
run: |

Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ COPY . .
2121
# Install dependencies (skipping install of Cypress binary)
2222
RUN CYPRESS_INSTALL_BINARY=0 yarn --pure-lockfile --no-cache
2323

24-
## Create project/env specific config
25-
RUN yarn build:config
26-
2724
## Build app bundle and index.html
2825
RUN yarn build
2926

cypress/integration/ProjectsPage.spec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ describe('Projects Page', () => {
9292
})
9393

9494
it('does not display the same project twice (even is creator is also collaborator)', () => {
95-
cy.get(createSelector('project-tile-name')).its('length').should('be', 3)
95+
// Confirm collab projects are being shown (needed to prevent check before collab projects loaded)
96+
cy.get(createIdSelector('collab-project-1')).should('exist')
97+
cy.get(createSelector('project-tile-name'))
98+
.its('length')
99+
.should('equal', 3)
96100
})
97101
})
98102
})

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"clean": "rimraf build",
77
"size": "size-limit",
88
"build": "react-scripts build",
9-
"build:config": "firebase-ci createConfig",
109
"build:size": "yarn build && size-limit",
1110
"build:size:why": "yarn build && yarn size --why",
1211
"start": "react-scripts start",
@@ -88,7 +87,7 @@
8887
"eslint-plugin-react-hooks": "^4.1.2",
8988
"eslint-plugin-standard": "^4.0.1",
9089
"firebase-admin": "^9.2.0",
91-
"firebase-ci": "^0.14.0",
90+
"firebase-ci": "^0.15.0",
9291
"firebase-tools": "8.12.0",
9392
"husky": "^4.2.5",
9493
"lint-staged": "^10.2.11",

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7108,16 +7108,16 @@ firebase-admin@^9.2.0:
71087108
"@google-cloud/firestore" "^4.0.0"
71097109
"@google-cloud/storage" "^5.3.0"
71107110

7111-
firebase-ci@^0.14.0:
7112-
version "0.14.0"
7113-
resolved "https://registry.yarnpkg.com/firebase-ci/-/firebase-ci-0.14.0.tgz#dce5a4733deb33eeaf6de353a8541f4dfc0e3ab3"
7114-
integrity sha512-EapJbOPKD3AsWrkATDNRFH20mF6cXcsya2YuyJx4BGTPz8Bh8luRkqdU1Ub0V+0Yz11QCw5UUdU9Q2zoNtCz2Q==
7111+
firebase-ci@^0.15.0:
7112+
version "0.15.0"
7113+
resolved "https://registry.yarnpkg.com/firebase-ci/-/firebase-ci-0.15.0.tgz#2053975fb8206e5512656445814529da652a9289"
7114+
integrity sha512-4/cEmTt9i3GO96sakuS3Wvp3xAE3bpkF4vKUdFsSe5wLQvXbd0ohfrUPYiE2THdZ6Ntj8LDNGe7vGiO2va98Kg==
71157115
dependencies:
71167116
chalk "^3.0.0"
71177117
command-exists "^1.2.8"
71187118
commander "^4.1.0"
71197119
figures "^3.1.0"
7120-
lodash "^4.17.15"
7120+
lodash "^4.17.20"
71217121

71227122
71237123
version "8.12.0"

0 commit comments

Comments
 (0)