Skip to content

Commit

Permalink
Personas github action (#1553)
Browse files Browse the repository at this point in the history
- [x] Modify Dockerfile to work in this repo
- [x] Create GitHub Action Workflow to deploy Personas to Cloud Run
- [x] Add secrets to prod environment
  • Loading branch information
beastoin authored Dec 16, 2024
2 parents f83377a + e6e211a commit 97b1003
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 21 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/gcp_personas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Deploy Personas to Cloud RUN

on:
push:
branches: [ "main", "development" ]
paths:
- 'personas-open-source/**'
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy from'
required: true
default: 'main'


env:
SERVICE: omi-web
REGION: us-central1

jobs:
deploy:
environment: ${{ (github.ref == 'refs/heads/development' && 'development') || (github.ref == 'refs/heads/main' && 'prod') }}
permissions:
contents: 'read'
id-token: 'write'

runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- run: gcloud auth configure-docker
- name: Build and Push Docker image
run: |
docker build \
--build-arg NEXT_PUBLIC_FIREBASE_API_KEY=${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }} \
--build-arg NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }} \
--build-arg NEXT_PUBLIC_FIREBASE_PROJECT_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }} \
--build-arg NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }} \
--build-arg NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }} \
--build-arg NEXT_PUBLIC_FIREBASE_APP_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }} \
--build-arg NEXT_PUBLIC_RAPIDAPI_KEY=${{ secrets.NEXT_PUBLIC_RAPIDAPI_KEY }} \
--build-arg NEXT_PUBLIC_RAPIDAPI_HOST=${{ secrets.NEXT_PUBLIC_RAPIDAPI_HOST }} \
--build-arg CLAUDE_API_KEY=${{ secrets.CLAUDE_API_KEY }} \
--build-arg NEXT_PUBLIC_FIREBASE_VAPID_KEY=${{ secrets.NEXT_PUBLIC_FIREBASE_VAPID_KEY }} \
--build-arg OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }} \
--build-arg NEXT_PUBLIC_MIXPANEL_TOKEN=${{ secrets.NEXT_PUBLIC_MIXPANEL_TOKEN }} \
--build-arg NEXT_PUBLIC_EXTRA_PROMPT_RULES=${{ secrets.NEXT_PUBLIC_EXTRA_PROMPT_RULES }} \
-t gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }} \
-f personas-open-source/Dockerfile .
docker push gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v0
with:
service: ${{ env.SERVICE }}
region: ${{ env.REGION }}
image: gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}

# If required, use the Cloud Run url output in later steps
- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}
16 changes: 4 additions & 12 deletions personas-open-source/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
# Use Node.js LTS version
FROM node:18-alpine

# Set working directory
FROM node:18-alpine AS base
WORKDIR /app

# Copy package files
COPY package*.json ./
# Copy all files
COPY personas-open-source .

# Install dependencies and types
RUN npm install --legacy-peer-deps && \
RUN npm ci --legacy-peer-deps && \
npm install --save-dev @types/mixpanel-browser --legacy-peer-deps
# && \
# npm install --save-dev @types/mixpanel-browser --legacy-peer-deps

# Copy all files
COPY . .

# Environment variables should be passed at build time
ARG NEXT_PUBLIC_FIREBASE_API_KEY
Expand Down
9 changes: 9 additions & 0 deletions personas-open-source/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import next from 'next';
const NextConfig = next.default;

const nextConfig = {
output: 'standalone',
/* other config options */
};

export default nextConfig;
8 changes: 0 additions & 8 deletions personas-open-source/next.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion personas-open-source/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "next.config.mjs"],
"exclude": ["node_modules"]
}

0 comments on commit 97b1003

Please sign in to comment.