Skip to content

Merge pull request #100 from SunbirdAI/solving-google-auth-bug #84

Merge pull request #100 from SunbirdAI/solving-google-auth-bug

Merge pull request #100 from SunbirdAI/solving-google-auth-bug #84

Workflow file for this run

name: Deploy to Cloud Run
on:
push:
branches:
- main # Update the branch as needed
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Checkout the code
- name: Checkout code
uses: actions/checkout@v3
# Set up Python environment (for Alembic)
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10" # Specify the Python version
# Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt # Ensure Alembic is in your requirements
# Set up Google Cloud authentication
- name: Authenticate to Google Cloud
uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
# Set up Google Cloud SDK
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
# Run Alembic migrations
- name: Run Alembic migrations
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }} # Ensure this is set in your repo secrets
run: |
alembic upgrade head # Runs the migration to the latest version
# Authenticate Docker with GCP
- name: Authenticate Docker
run: |
gcloud auth configure-docker
# Build and submit Docker image to Google Container Registry (GCR)
- name: Build and submit Docker image
run: |
export TAG=gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.APP_NAME }}
gcloud builds submit --tag $TAG
continue-on-error: true
# Deploy to Cloud Run
- name: Deploy to Cloud Run
run: |
export APP=${{ secrets.APP_NAME }}
export TAG=gcr.io/${{ secrets.GCP_PROJECT_ID }}/${APP}
export REGION=${{ secrets.GCP_REGION }}
gcloud run deploy $APP --image $TAG --platform managed --region $REGION --allow-unauthenticated