-
Notifications
You must be signed in to change notification settings - Fork 141
103 lines (101 loc) · 9.13 KB
/
deploy.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
name: Deploy to Firebase
on:
push:
branches:
- master
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
FIREBASE_SERVICE_ACCOUNT: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
GCLOUD_PROJECT: ${{ secrets.GCLOUD_PROJECT }}
MAIN_KEY: ${{ secrets.MAIN_KEY }}
MONGO_URI: ${{ secrets.MONGO_URI }}
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
SENDGRID_NEW_DEVELOPER_ACCOUNT_TEMPLATE: ${{ secrets.NEW_DEVELOPER_ACCOUNT_TEMPLATE }}
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
GA_API_SECRET: ${{ secrets.GA_API_SECRET }}
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_URL: ${{ secrets.REDIS_URL }}
REDIS_PORT: ${{ secrets.REDIS_PORT }}
REDIS_USERNAME: ${{ secrets.REDIS_USERNAME }}
REDIS_STATUS: ${{ secrets.REDIS_STATUS }}
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
GITHUB_STATS_TOKEN: ${{ secrets.STATS_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_REGION: ${{ secrets.AWS_REGION }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_ENDPOINT_SECRET: ${{ secrets.STRIPE_ENDPOINT_SECRET }}
NODE_ENV: production
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install Project Dependencies
run: |
rm -rf ./node_modules; npm install
npm install -g firebase-tools
- name: Install Cloud Dependencies
run: |
cd functions; rm -rf ./node_modules/; npm install; cd ..; pwd
firebase use default --token $FIREBASE_TOKEN
- name: Create .env
run: touch ./functions/.env
- name: Update .env
uses: SpicyPizza/create-envfile@v2.0
with:
envkey_ENV_VPC_CONNECTOR: ${{ secrets.VPC_CONNECTOR }}
envkey_ENV_REDIS_PORT: ${{ secrets.REDIS_PORT }}
envkey_ENV_MONGO_URI: ${{ secrets.MONGO_URI }}
envkey_ENV_REDIS_URL: ${{ secrets.REDIS_URL }}
envkey_ENV_REDIS_HOST: ${{ secrets.REDIS_HOST }}
envkey_ENV_CLIENT_TEST: false
envkey_ENV_REDIS_USERNAME: ${{ secrets.REDIS_USERNAME }}
envkey_ENV_FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
envkey_ENV_FIREBASE_SERVICE_ACCOUNT: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
envkey_ENV_REDIS_STATUS: true
envkey_ENV_REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
envkey_ENV_MAIN_KEY: ${{ secrets.MAIN_KEY }}
envkey_ENV_REPLICA_SET: true
envkey_ANALYTICS_GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
envkey_ANALYTICS_GA_API_SECRET: ${{ secrets.GA_API_SECRET }}
envkey_SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
envkey_SENDGRID_NEW_DEVELOPER_ACCOUNT_TEMPLATE: ${{ secrets.NEW_DEVELOPER_ACCOUNT_TEMPLATE }}
envkey_GITHUB_STATS_TOKEN: ${{ secrets.STATS_TOKEN }}
envkey_AWS_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
envkey_AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }}
envkey_AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
envkey_AWS_REGION: ${{ secrets.AWS_REGION }}
envkey_RUNTIME_ENV: "production"
envkey_STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
envkey_STRIPE_ENDPOINT_SECRET: ${{ secrets.STRIPE_ENDPOINT_SECRET }}
envkey_ENV_IGBO_STT_URL: ${{ secrets.ENV_IGBO_STT_URL }}
envkey_ENV_IGBO_TO_ENGLISH_URL: ${{ secrets.ENV_IGBO_TO_ENGLISH_URL }}
envkey_ENV_ENGLISH_TO_IGBO_URL: ${{ secrets.ENV_ENGLISH_TO_IGBO_URL }}
directory: functions
- name: Build Production Project
run: |
firebase functions:config:set runtime.env=production --token $FIREBASE_TOKEN
npm run build
- name: Migrate MongoDB Data
run: |
firebase functions:config:set env.redis_status=true runtime.env=production --token $FIREBASE_TOKEN
npm run migrate-up
- name: Deploy Production Firebase Functions
run: |
firebase deploy --project=igbo-api-bb22d --only functions
- name: Deploy Production Firebase Hosting
run: |
firebase deploy --project=igbo-api-bb22d --only hosting
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
- name: Delete .env
run: rm -rf ./functions/.env