Skip to content

Commit

Permalink
Merge pull request #10 from its-kunal/develop
Browse files Browse the repository at this point in the history
changes for BE CI/CD.
  • Loading branch information
its-kunal authored Feb 17, 2025
2 parents f0797e4 + 5269fa5 commit e47c035
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 13 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/deploy-backend-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Deploy to Google Cloud Run Production

on:
push:
branches:
- main
paths:
- 'server/**'
workflow_dispatch:

permissions:
id-token: write
contents: read

jobs:
build_and_deploy:
runs-on: ubuntu-latest
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
APP: chatterbox
REGION: asia-south1
GAR_LOCATION: asia-south1
steps:
- name: "Checkout Server Code"
uses: actions/checkout@v4
with:
sparse-checkout: server
- name: "Google Auth"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
service_account: "${{ secrets.WIF_SERVICE_ACCOUNT }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
with:
project_id: "${{ secrets.PROJECT_ID }}"
- name: "Docker auth"
run: |-
gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev
- name: "Build and push container"
run: |-
docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.APP }}/${{ env.APP }}:production" ./server
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.APP }}/${{ env.APP }}:production"
- name: "Cloud Run Release"
run : |-
gcloud run services describe my-chat-server --region ${{ env.GAR_LOCATION }} --format export > service.yaml
gcloud run services replace service.yaml
47 changes: 47 additions & 0 deletions .github/workflows/deploy-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and Deploy to Google Cloud Run

on:
workflow_dispatch:

pull_request:
paths:
- "server/**"

permissions:
id-token: write
contents: read

jobs:
build_and_deploy:
runs-on: ubuntu-latest
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
APP: chatterbox
REGION: asia-south1
GAR_LOCATION: asia-south1
steps:
- name: "Checkout Server Code"
uses: actions/checkout@v4
with:
sparse-checkout: server
- name: "Google Auth"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
service_account: "${{ secrets.WIF_SERVICE_ACCOUNT }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
with:
project_id: "${{ secrets.PROJECT_ID }}"
- name: "Docker auth"
run: |-
gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev
- name: "Build and push container"
run: |-
docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.APP }}/${{ env.APP }}:staging" ./server
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.APP }}/${{ env.APP }}:staging"
- name: "Cloud Run Release"
run : |-
gcloud run services describe chatterbox-staging --region ${{ env.GAR_LOCATION }} --format export > service.yaml
gcloud run services replace service.yaml
1 change: 0 additions & 1 deletion .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
pull_request:
paths:
- 'client/**' # Only trigger on changes in the client directory
- '.github/**'
workflow_dispatch: # Allows manual triggering

permissions:
Expand Down
6 changes: 3 additions & 3 deletions client/src/screens/auth/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Button, Container, Divider, Typography } from "@mui/material";
import HeroSvg from "./HeroSvg.svg";
import { Button, Container, Typography } from "@mui/material";
import HeroSvg from "./HeroSvg.svg?react";
import { Google } from "@mui/icons-material";
import {
GoogleAuthProvider,
Expand Down Expand Up @@ -52,7 +52,7 @@ function Auth() {
flexDirection: "column",
rowGap: 2,
my: 1,
maxHeight: 600
maxHeight: 600,
}}
>
<HeroSvg />
Expand Down
5 changes: 2 additions & 3 deletions client/src/screens/chat/ChatList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BotSVG from "../../assets/bot.svg";
import BotSVG from "../../assets/bot.svg?react";
import { thumbs } from "@dicebear/collection";
import { createAvatar } from "@dicebear/core";
import {
Expand Down Expand Up @@ -47,7 +47,6 @@ function MyListItemText({ chat }: { chat: ChatV2 }) {
}

function MyListItemAudio({ chat }: { chat: ChatV2 }) {

const audioSrc = `data:audio/webm;base64,${chat.data}`;
// console.log(audioURL);
return (
Expand Down Expand Up @@ -106,7 +105,7 @@ export default function ChatList() {
<ListItem key={idx}>
<ListItemIcon title={chat.user.displayName || "Anonymous"}>
{chat.user.displayName === "Chatterbot" ? (
<img src={BotSVG} height={30} width={30} />
<BotSVG height={30} width={30} />
) : (
(() => {
const avatar = createAvatar(thumbs, {
Expand Down
1 change: 1 addition & 0 deletions client/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// <reference types="vite/client" />
/// <reference types="vite-plugin-svgr/client" />
7 changes: 1 addition & 6 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,5 @@ import svgr from "vite-plugin-svgr";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
svgr({
include: "**/*.svg",
}),
],
plugins: [react(), svgr()],
});
4 changes: 4 additions & 0 deletions server/app/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ app.get("/user", async (req, res) => {
res.send("done");
});

app.get("/hello", async (req, res) => {
res.send("Hello from chatterbox!");
});

export { app };

0 comments on commit e47c035

Please sign in to comment.