Merge pull request #103 from SunbirdAI/solving-google-auth-bug #87
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 to Cloud Run | |
on: | |
push: | |
branches: | |
- main # Update the branch as needed | |
# pull_request: | |
# branches: | |
# - main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# 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 | |
# 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 |