Skip to content

Commit 6bf280c

Browse files
Merge pull request #7 from Luar6/dev
Everything working properly on Vercel
2 parents 26777db + d30bd6d commit 6bf280c

6 files changed

Lines changed: 60 additions & 39 deletions

File tree

.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Firebase Service Account Credentials
2+
3+
TYPE=service_account
4+
PROJECT_ID=your-project-id
5+
PRIVATE_KEY_ID=your-private-key-id
6+
PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\\nYOUR_KEY_LINE_1\\nYOUR_KEY_LINE_2\\n-----END PRIVATE KEY-----\\n
7+
CLIENT_EMAIL=your-service-account@your-project.iam.gserviceaccount.com
8+
CLIENT_ID=your-client-id
9+
AUTH_URI=https://accounts.google.com/o/oauth2/auth
10+
TOKEN_URI=https://oauth2.googleapis.com/token
11+
AUTH_PROVIDER_CERT_URL=https://www.googleapis.com/oauth2/v1/certs
12+
CLIENT_CERT_URL=https://www.googleapis.com/robot/v1/metadata/x509/your-service-account%40your-project.iam.gserviceaccount.com
13+
14+
# Firebase Realtime Database URL
15+
DATABASE_URL=https://your-project-id-default-rtdb.firebaseio.com/

.github/workflows/preview.yml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
name: Vercel Preview Deployment
22

3-
env:
4-
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
5-
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
6-
73
on:
8-
push:
9-
branches-ignore:
10-
- main
4+
push:
5+
branches-ignore:
6+
- main
117

128
jobs:
13-
Deploy-Preview:
14-
runs-on: ubuntu-latest
15-
steps:
9+
Deploy-Preview:
10+
runs-on: ubuntu-latest
11+
env:
12+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
13+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1614

17-
- uses: actions/checkout@v3
15+
steps:
16+
- uses: actions/checkout@v3
1817

19-
- name: Install Vercel CLI
20-
run: npm install --global vercel
18+
- name: Install Vercel CLI
19+
run: npm install --global vercel
2120

22-
- name: Pull Vercel Environment Information
23-
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
21+
- name: Pull Vercel Environment Information
22+
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
2423

25-
- name: Build Project Artifacts
26-
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
24+
- name: Build Project Artifacts
25+
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
2726

28-
- name: Deploy Project Artifacts
29-
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
27+
- name: Deploy Project Artifacts
28+
run: vercel deploy --prebuilt --archive=tgz --token=${{ secrets.VERCEL_TOKEN }}

.github/workflows/production.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Vercel Production Deployment
22

3-
env:
4-
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
5-
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
6-
73
on:
84
push:
95
branches:
@@ -12,21 +8,14 @@ on:
128
jobs:
139
Deploy-Production:
1410
runs-on: ubuntu-latest
15-
steps:
11+
env:
12+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
13+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1614

15+
steps:
1716
- name: Checkout repository
1817
uses: actions/checkout@v3
1918

20-
- name: Set up Python
21-
uses: actions/setup-python@v4
22-
with:
23-
python-version: '3.13.3'
24-
25-
- name: Install Python dependencies
26-
run: |
27-
python3 -m pip install --upgrade pip
28-
pip install -r requirements.txt
29-
3019
- name: Install Vercel CLI
3120
run: npm install --global vercel
3221

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
credentials.json
21
.vercel
2+
.env

api/main.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,26 @@
55
from phonenumbers import PhoneNumberFormat
66
import uuid
77
from datetime import datetime
8-
9-
cred = credentials.Certificate("credentials.json")
10-
firebase_admin.initialize_app(cred, {"databaseURL": "https://if-project-3ded1-default-rtdb.firebaseio.com/"})
8+
import os
9+
from dotenv import load_dotenv
10+
11+
load_dotenv()
12+
13+
cred_info = {
14+
"type": os.getenv("TYPE"),
15+
"project_id": os.getenv("PROJECT_ID"),
16+
"private_key_id": os.getenv("PRIVATE_KEY_ID"),
17+
"private_key": os.getenv("PRIVATE_KEY").replace("\\n", "\n"),
18+
"client_email": os.getenv("CLIENT_EMAIL"),
19+
"client_id": os.getenv("CLIENT_ID"),
20+
"auth_uri": os.getenv("AUTH_URI"),
21+
"token_uri": os.getenv("TOKEN_URI"),
22+
"auth_provider_x509_cert_url": os.getenv("AUTH_PROVIDER_CERT_URL"),
23+
"client_x509_cert_url": os.getenv("CLIENT_CERT_URL")
24+
}
25+
26+
cred = credentials.Certificate(cred_info)
27+
firebase_admin.initialize_app(cred, {"databaseURL": os.getenv("DATABASE_URL")})
1128

1229
ref = db.reference("/")
1330
agenda_ref = ref.child('agenda')

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
fastapi[standard]
22
firebase_admin
3-
phonenumbers
3+
phonenumbers
4+
python-dotenv

0 commit comments

Comments
 (0)