-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (61 loc) · 2.95 KB
/
firebase_deploy.yaml
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
name: Continuous deployment to firebase hosting
on:
workflow_dispatch:
inputs:
targetedHackathon:
description: 'Targetted hackathon to build'
required: true
push:
branches: [nwhacks2025_dev, nwhacks2025_main]
jobs:
firebase_deploy:
runs-on: ubuntu-latest
env:
IS_PRODUCTION: ${{ endsWith(github.ref, 'main') || endsWith(github.event.inputs.targetedHackathon, 'main') }}
GOOGLE_APPLICATION_CREDENTIALS: google-application-credentials.json
steps:
- uses: actions/checkout@v3
# TEMP FIX FOR NODE ERRORS
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
- name: Prepare google app credentials (dev)
if: ${{ env.IS_PRODUCTION == 'false' }}
run: echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT_NWPLUS_UBC_DEV_BASE_64 }}" | base64 --decode > "google-application-credentials.json"
- name: Prepare google app credentials (prod)
if: ${{ env.IS_PRODUCTION == 'true' }}
run: echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT_NWPLUS_UBC }}" | base64 --decode > "google-application-credentials.json"
- name: Set up firebase
run: sudo npm install -g [email protected] --unsafe
- name: Choose dev firebase project
if: ${{ env.IS_PRODUCTION == 'false' }}
run: firebase use ${{ secrets.DEV_FIREBASE_PROJECT_ID }}
- name: Choose prod firebase project
if: ${{ env.IS_PRODUCTION == 'true' }}
run: firebase use ${{ secrets.PROD_FIREBASE_PROJECT_ID }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build with dev env variables
if: ${{ env.IS_PRODUCTION == 'false' }}
run: yarn build:staging
env:
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.DEV_FIREBASE_API_KEY }}
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.DEV_FIREBASE_AUTH_DOMAIN }}
NEXT_PUBLIC_FIREBASE_DATABASE_URL: ${{ secrets.DEV_FIREBASE_DATABASE_URL }}
NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.DEV_FIREBASE_PROJECT_ID }}
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.DEV_FIREBASE_STORAGE_BUCKET }}
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.DEV_FIREBASE_MESSAGING_SENDER_ID }}
NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.DEV_FIREBASE_APP_ID }}
- name: Build with prod env variables
if: ${{ env.IS_PRODUCTION == 'true' }}
run: yarn build:prod
- name: Check for targeted hackathon
if: ${{ !github.event.inputs.targetedHackathon }}
run: firebase deploy --only hosting:${GITHUB_REF#refs/*/} --non-interactive
- name: Deploy to site associated with branch name
if: ${{ github.event.inputs.targetedHackathon }}
run: firebase deploy --only hosting:${{ github.event.inputs.targetedHackathon }} --non-interactive
- name: Remove credentials file
if: success() || failure()
run: rm google-application-credentials.json