diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8a835e1 --- /dev/null +++ b/.env.example @@ -0,0 +1,15 @@ +# Firebase Service Account Credentials + +TYPE=service_account +PROJECT_ID=your-project-id +PRIVATE_KEY_ID=your-private-key-id +PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\\nYOUR_KEY_LINE_1\\nYOUR_KEY_LINE_2\\n-----END PRIVATE KEY-----\\n +CLIENT_EMAIL=your-service-account@your-project.iam.gserviceaccount.com +CLIENT_ID=your-client-id +AUTH_URI=https://accounts.google.com/o/oauth2/auth +TOKEN_URI=https://oauth2.googleapis.com/token +AUTH_PROVIDER_CERT_URL=https://www.googleapis.com/oauth2/v1/certs +CLIENT_CERT_URL=https://www.googleapis.com/robot/v1/metadata/x509/your-service-account%40your-project.iam.gserviceaccount.com + +# Firebase Realtime Database URL +DATABASE_URL=https://your-project-id-default-rtdb.firebaseio.com/ diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index bffb9f9..e7ab10f 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -1,29 +1,28 @@ name: Vercel Preview Deployment -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - on: - push: - branches-ignore: - - main + push: + branches-ignore: + - main jobs: - Deploy-Preview: - runs-on: ubuntu-latest - steps: + Deploy-Preview: + runs-on: ubuntu-latest + env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - - uses: actions/checkout@v3 + steps: + - uses: actions/checkout@v3 - - name: Install Vercel CLI - run: npm install --global vercel + - name: Install Vercel CLI + run: npm install --global vercel - - name: Pull Vercel Environment Information - run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} - - name: Build Project Artifacts - run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Project Artifacts + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} - - name: Deploy Project Artifacts - run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts + run: vercel deploy --prebuilt --archive=tgz --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index f26c149..703f74c 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -1,9 +1,5 @@ name: Vercel Production Deployment -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - on: push: branches: @@ -12,21 +8,14 @@ on: jobs: Deploy-Production: runs-on: ubuntu-latest - steps: + env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.13.3' - - - name: Install Python dependencies - run: | - python3 -m pip install --upgrade pip - pip install -r requirements.txt - - name: Install Vercel CLI run: npm install --global vercel diff --git a/.gitignore b/.gitignore index 304a0ce..83baf96 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -credentials.json .vercel +.env \ No newline at end of file diff --git a/api/main.py b/api/main.py index 81e3c76..b60cda1 100644 --- a/api/main.py +++ b/api/main.py @@ -5,9 +5,26 @@ from phonenumbers import PhoneNumberFormat import uuid from datetime import datetime - -cred = credentials.Certificate("credentials.json") -firebase_admin.initialize_app(cred, {"databaseURL": "https://if-project-3ded1-default-rtdb.firebaseio.com/"}) +import os +from dotenv import load_dotenv + +load_dotenv() + +cred_info = { + "type": os.getenv("TYPE"), + "project_id": os.getenv("PROJECT_ID"), + "private_key_id": os.getenv("PRIVATE_KEY_ID"), + "private_key": os.getenv("PRIVATE_KEY").replace("\\n", "\n"), + "client_email": os.getenv("CLIENT_EMAIL"), + "client_id": os.getenv("CLIENT_ID"), + "auth_uri": os.getenv("AUTH_URI"), + "token_uri": os.getenv("TOKEN_URI"), + "auth_provider_x509_cert_url": os.getenv("AUTH_PROVIDER_CERT_URL"), + "client_x509_cert_url": os.getenv("CLIENT_CERT_URL") +} + +cred = credentials.Certificate(cred_info) +firebase_admin.initialize_app(cred, {"databaseURL": os.getenv("DATABASE_URL")}) ref = db.reference("/") agenda_ref = ref.child('agenda') diff --git a/requirements.txt b/requirements.txt index 6af070e..4db9a8d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ fastapi[standard] firebase_admin -phonenumbers \ No newline at end of file +phonenumbers +python-dotenv \ No newline at end of file