Skip to content

Commit

Permalink
Add deploy step to .yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sofvanh committed Nov 14, 2024
1 parent 3babca4 commit 83c1616
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/backend-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Backend
name: Build and Deploy Backend

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
- 'frontend/src/shared/**'

jobs:
build:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -39,10 +39,38 @@ jobs:
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1

- name: Check for required secrets
run: |
required_secrets=("OPENAI_API_KEY" "DB_USER" "DB_HOST" "DB_NAME" "DB_PASSWORD" "GOOGLE_CLIENT_ID")
missing_secrets=()
for secret in "${required_secrets[@]}"; do
if [ -z "${{ secrets[secret] }}" ]; then
missing_secrets+=("$secret")
fi
done
if [ ${#missing_secrets[@]} -ne 0 ]; then
echo "Error: The following required secrets are missing:"
for secret in "${missing_secrets[@]}"; do
echo "- $secret"
done
exit 1
fi
echo "All required secrets are present. Proceeding with deployment..."
- name: Build and Push Image
run: |
cd backend
echo "Starting Cloud Build..."
gcloud builds submit --tag gcr.io/mindmeld-backend/mindmeld:${{ steps.version.outputs.version }} --async
echo "Build submitted successfully!"
echo "You can view the build progress at: https://console.cloud.google.com/cloud-build/builds"
echo "You can view the build progress at: https://console.cloud.google.com/cloud-build/builds"
- name: Deploy to Cloud Run
run: |
gcloud run deploy mindmeld \
--image gcr.io/mindmeld-backend/mindmeld:${{ steps.version.outputs.version }} \
--add-cloudsql-instances ${{ secrets.CLOUD_SQL_CONNECTION_NAME }} \
--set-secrets=OPENAI_API_KEY=OPENAI_API_KEY:latest,DB_USER=DB_USER:latest,DB_HOST=DB_HOST:latest,DB_NAME=DB_NAME:latest,DB_PASSWORD=DB_PASSWORD:latest,GOOGLE_CLIENT_ID=GOOGLE_CLIENT_ID:latest \
--platform managed \
--region europe-west1 \
--allow-unauthenticated

0 comments on commit 83c1616

Please sign in to comment.