Skip to content

Commit

Permalink
change firebase env to base64
Browse files Browse the repository at this point in the history
  • Loading branch information
devadathanmb committed Oct 30, 2023
1 parent cc9628f commit acc54d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ jobs:
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/ktu-bot:latest ktu-bot:latest
docker stop ktu-bot || true
docker rm ktu-bot || true
docker run --restart always -d -e BOT_TOKEN=${{ secrets.BOT_TOKEN }} -e FIREBASE_SERVICE_ACCOUNT="${{ secrets.FIREBASE_SERVICE_ACCOUNT }}" ktu-bot
docker run -d --restart always -e BOT_TOKEN=${{ secrets.BOT_TOKEN }} -e FIREBASE_SERVICE_ACCOUNT="${{ secrets.FIREBASE_SERVICE_ACCOUNT }}" ktu-bot
8 changes: 7 additions & 1 deletion src/db/initDb.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { initializeApp, cert } from "firebase-admin/app";
import { getFirestore } from "firebase-admin/firestore";

const serviceAccount = JSON.parse(process.env.FIREBASE_SERVICE_ACCOUNT!);
// I wasted an entire day trying to pass a json to docker run env
// life is too short for ci
const base64ServiceAccount = process.env.FIREBASE_SERVICE_ACCOUNT!;
const serviceAccountBuffer = Buffer.from(base64ServiceAccount, "base64");
const serviceAccountJson = serviceAccountBuffer.toString("utf-8");

const serviceAccount = JSON.parse(serviceAccountJson);

function initDb() {
initializeApp({
Expand Down

0 comments on commit acc54d0

Please sign in to comment.