-
Notifications
You must be signed in to change notification settings - Fork 79
144 lines (138 loc) · 4.08 KB
/
nodejs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Build, Test, Deploy
on: [push, pull_request]
jobs:
#########################
## Site Build & Testing
#########################
build-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Examine Node
run: |
node -v
npm -v
- name: Determine Lockfile
id: lockfile
run: |
if [[ -f "package-lock.json" || -f "npm-shrinkwrap.json" ]]; then
echo "::set-output name=exists::true"
else
echo "::set-output name=exists::false"
fi
- name: Install - Lockfile
if: steps.lockfile.outputs.exists == 'true'
run: |
npm ci --no-optional
- name: Install - No Lockfile
if: steps.lockfile.outputs.exists == 'false'
run: |
npm install
- name: Install CLI dependencies
run: |
sudo apt-get update
sudo apt-get install giflib-tools webp ffmpeg
- name: Build and Test
run: |
npm test
npm run build --if-present
env:
CI: true
- name: Upload built state
uses: actions/upload-artifact@v1
with:
name: site
path: public
# Needed for redirect building
- name: Upload firebase.json with redirects
uses: actions/upload-artifact@v1
with:
name: firebase
path: firebase.json
# Needed for functions deploy
- name: Upload search index state
uses: actions/upload-artifact@v1
if: github.ref == 'refs/heads/main'
with:
name: indexes
path: functions/indexes
#########################
## Preview Deploy
#########################
preview:
needs: build-test
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download compiled site
uses: actions/download-artifact@v1
with:
name: site
path: public
- name: Remove firebase.json without redirects
run: |
rm firebase.json
- name: Download firebase.json with redirects
uses: actions/download-artifact@v3
with:
name: firebase
- name: Deploy Hosting Preview
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_CROS_STAGING }}'
expires: 30d
#########################
## Production Deploy
#########################
deploy:
needs: build-test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download compiled site
uses: actions/download-artifact@v1
with:
name: site
path: public
- name: Remove firebase.json without redirects
run: |
rm firebase.json
- name: Download firebase.json with redirects
uses: actions/download-artifact@v3
with:
name: firebase
- name: Download compiled indexes
uses: actions/download-artifact@v1
with:
name: indexes
path: functions/indexes
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install functions dependencies
if: github.ref == 'refs/heads/main'
run: |
npm ci --prefix functions
- name: Deploy Hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_CROS_STAGING }}'
channelId: live
- name: Deploy Functions
uses: w9jds/[email protected]
with:
args: deploy --only functions
env:
GCP_SA_KEY: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CROS_STAGING }}