-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (62 loc) · 2.38 KB
/
deploy_functions.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
name: Deploy to DEV
on:
push:
branches:
- stg
workflow_dispatch:
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the code
- uses: actions/checkout@v3
# Step 1.5: Environment variables
- name: create env file
working-directory: backend
run: |
cd functions
touch .env
echo "${{ secrets.FUNCTIONS_ENV_VARS }}" >> .env
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
# Step 3: Set up Node.js environment
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 19.7.0
# Step 3.5: Download the ZIP file from Google Drive
- name: Download Models ZIP
run: |
FILE_ID="YOUR_GOOGLE_DRIVE_FILE_ID"
wget --no-check-certificate "https://drive.google.com/uc?export=download&id=1VaPJNto0HusO3ziQDLSUQwrlvNgPOKel" -O /tmp/cookie \
&& CONFIRM=$(awk '/download/ {print $NF}' /tmp/cookie) \
&& wget --load-cookies /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CONFIRM}&id=1VaPJNto0HusO3ziQDLSUQwrlvNgPOKel" -O models.zip
# Step 3.5.2: Extract the ZIP file
- name: Extract Models ZIP
run: |
unzip models.zip -d backend/functions/ml_logic
# Step 3.5.3: Clean up
- name: Clean Up
run: rm models.zip
# Step 4: Create Service Account Key and Set Env Variables
- name: Create SA key and set env variables
run: |
echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT_SCHEMESSG_V3_DEV }}' > ${{ runner.temp }}/gcloud.json
echo "GOOGLE_APPLICATION_CREDENTIALS=${{ runner.temp }}/gcloud.json" >> $GITHUB_ENV
# Step 5: Prepare the environment
- name: Prepare the environment
working-directory: backend/functions
run: |
python3.10 -m venv venv
. venv/bin/activate
npx firebase-tools --version
python3.10 -m pip install -r requirements.txt
# Step 6: deploy functions
- name: Deploy functions
working-directory: backend
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ runner.temp }}/gcloud.json
run: npx firebase-tools deploy --only functions --debug --token "${{ secrets.FIREBASE_TOKEN_SCHEMESSG_V3_DEV }}"