Deploy Backend #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Backend | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
tags: | |
description: 'Branch or tag (e.g: v0.0.1)' | |
required: false | |
type: string | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
# needs: build-and-push-backend-image | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
- name: Set up environment variables | |
run: | | |
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> $GITHUB_ENV | |
echo "COHERE_API_KEY=${{ secrets.COHERE_API_KEY }}" >> $GITHUB_ENV | |
echo "GCP_PROJECT_ID=${{ secrets.GCP_PROJECT_ID }}" >> $GITHUB_ENV | |
echo "IMAGE_TAG=${{ github.event.inputs.tags }}" >> $GITHUB_ENV | |
# Deploy the image to Cloud Run | |
- name: Deploy to Cloud Run | |
# env: | |
# Database_URL: ${{ secrets.DATABASE_URL }} | |
# COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} | |
# GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
# IMAGE_NAME: ${{ env.IMAGE_NAME }} | |
run: | | |
gcloud run deploy ${{ env.IMAGE_NAME }} \ | |
--project=${{ env.GCP_PROJECT_ID }} \ | |
--image=${{ env.meta.outputs.tags }} \ | |
--platform=managed \ | |
--region=us-central1 \ | |
--allow-unauthenticated \ | |
--update-env-vars=DATABASE_URL=${{ env.DATABASE_URL }},COHERE_API_KEY=${{ env.COHERE_API_KEY }} \ | |
--memory=4Gi \ | |
--cpu=4 \ | |
--max-instances=1 | |
# steps: | |
# - name: Login | |
# uses: google-github-actions/setup-gcloud@v0 | |
# with: | |
# project_id: ${{ vars.GCP_PROJECT_ID }} | |
# service_account_email: [email protected] | |
# service_account_key: ${{ secrets.GCP_SA_KEY }} | |
# - name: Checkout repository | |
# uses: actions/checkout@v2 | |
# Deploy the image to Cloud Run |