Skip to content

Commit 8c3efc5

Browse files
authored
fix: deployment of firebase hosting (#37)
* fix: deployment of firebase hosting * fix: remove redundant lint * feat: add human readable name * fix: add note about it being staging * feat: setup cloud functions deployment * fix: remove predeploy ment from firebase json rather keep it inside packagejson scripts * fix: add artifact UPLOAD * fix: set path properly * disable main branch check * fix: TEMP disable cache timeout checks * fix: lint * feat: install firebase CLI * fix: add path as build * fix: add lib to path of download * fix: apparently need to run npm install * Revert "disable main branch check" This reverts commit dec71b5.
1 parent b12a0bf commit 8c3efc5

File tree

5 files changed

+115
-53
lines changed

5 files changed

+115
-53
lines changed

.github/workflows/backend.yaml

+63-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ on:
99
branches:
1010
- main
1111
jobs:
12-
ci_backend:
12+
lint:
13+
name: Lint
1314
runs-on: ubuntu-latest
1415
defaults:
1516
run:
@@ -31,5 +32,66 @@ jobs:
3132
run: npm ci --ignore-scripts --no-audit --no-progress
3233
- name: Lint
3334
run: npm run lint
35+
build:
36+
name: Build
37+
runs-on: ubuntu-latest
38+
defaults:
39+
run:
40+
working-directory: ./functions
41+
steps:
42+
- uses: actions/checkout@v2
43+
- name: Setup Node.js
44+
uses: actions/setup-node@v1
45+
with:
46+
node-version: 12
47+
- name: Cache npm dependencies
48+
uses: actions/cache@v1
49+
with:
50+
key: npm-${{ hashFiles('package-lock.json') }}
51+
path: ~/.npm
52+
restore-keys: |
53+
npm-
54+
- name: Install dependencies
55+
run: npm ci --ignore-scripts --no-audit --no-progress
3456
- name: Build
3557
run: npm run build
58+
- name: Share artifact inside workflow
59+
uses: actions/upload-artifact@v2
60+
with:
61+
name: functions-build
62+
path: functions/lib
63+
deploy:
64+
name: Deploy to Firebase Cloud Functions (Staging)
65+
if: github.ref == 'refs/heads/main'
66+
runs-on: ubuntu-latest
67+
needs: [ lint, build ]
68+
environment: staging
69+
defaults:
70+
run:
71+
working-directory: ./functions
72+
steps:
73+
- uses: actions/checkout@v2
74+
- name: Setup Node.js
75+
uses: actions/setup-node@v1
76+
with:
77+
node-version: 12
78+
- name: Cache npm dependencies
79+
uses: actions/cache@v1
80+
with:
81+
key: npm-${{ hashFiles('package-lock.json') }}
82+
path: ~/.npm
83+
restore-keys: |
84+
npm-
85+
- name: Install dependencies
86+
run: npm ci --ignore-scripts --no-audit --no-progress
87+
- name: Get artifact
88+
uses: actions/download-artifact@v2
89+
with:
90+
name: functions-build
91+
path: functions/lib
92+
- name: Install Firebase CLI
93+
run: npm install -g firebase-tools
94+
- name: Deploy to Firebase Cloud Functions
95+
run: firebase deploy --only functions
96+
env:
97+
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

.github/workflows/frontend-deploy.yml

-40
This file was deleted.

.github/workflows/frontend.yaml

+45-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ on:
1212
branches:
1313
- main
1414
jobs:
15-
ci_frontend:
15+
lint:
16+
name: Lint
1617
runs-on: ubuntu-latest
1718
steps:
1819
- uses: actions/checkout@v2
@@ -31,6 +32,49 @@ jobs:
3132
run: npm ci --ignore-scripts --no-audit --no-progress
3233
- name: Lint
3334
run: npm run lint
35+
build:
36+
name: Build
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v2
40+
- name: Setup Node.js
41+
uses: actions/setup-node@v1
42+
with:
43+
node-version: 12
44+
- name: Cache npm dependencies
45+
uses: actions/cache@v1
46+
with:
47+
key: npm-${{ hashFiles('package-lock.json') }}
48+
path: ~/.npm
49+
restore-keys: |
50+
npm-
51+
- name: Install dependencies
52+
run: npm ci --ignore-scripts --no-audit --no-progress
3453
- name: Build
3554
run: npm run build
55+
- name: Share artifact inside workflow
56+
uses: actions/upload-artifact@v2
57+
with:
58+
name: create-react-app-build
59+
path: build
60+
deploy:
61+
name: Deploy to Firebase Hosting (Staging)
62+
if: github.ref == 'refs/heads/main'
63+
runs-on: ubuntu-latest
64+
needs: [ lint, build ]
65+
environment: staging
66+
steps:
67+
- uses: actions/checkout@v2
68+
- name: Get artifact
69+
uses: actions/download-artifact@v2
70+
with:
71+
name: create-react-app-build
72+
path: build
73+
- name: Deploy to Firebase Hosting
74+
uses: FirebaseExtended/action-hosting-deploy@v0
75+
with:
76+
repoToken: "${{ secrets.GITHUB_TOKEN }}"
77+
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}"
78+
channelId: live
79+
projectId: staging-clockwork
3680

firebase.json

-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
"rules": "firestore.rules",
44
"indexes": "firestore.indexes.json"
55
},
6-
"functions": {
7-
"predeploy": [
8-
"npm --prefix \"$RESOURCE_DIR\" run lint",
9-
"npm --prefix \"$RESOURCE_DIR\" run build"
10-
]
11-
},
126
"hosting": {
137
"public": "build",
148
"ignore": [

functions/src/sections/Section.service.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ export class SectionsService {
5050
.doc(SectionsService.constructSectionKey(term, subject, code))
5151
.get();
5252

53-
const t = doc.data()?.retrievedAt?.getTime();
54-
// if retrievedAt exists and it wasn't retieved within 30 minutes
55-
if (t && t + 1000 * 1800 > Date.now()) {
56-
return undefined;
57-
}
53+
// FIX: serialization to and from firestore isn't working as expected
54+
// disable document staleness check for now.
55+
// const t = doc.data()?.retrievedAt?.getTime();
56+
// // if retrievedAt exists and it wasn't retieved within 30 minutes
57+
// if (t && t + 1000 * 1800 > Date.now()) {
58+
// return undefined;
59+
// }
5860
return doc.data();
5961
}
6062

0 commit comments

Comments
 (0)