Merge pull request #40 from Pyronewbic/dev #16
This file contains hidden or 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 | |
| on: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| id-token: write | |
| env: | |
| PROJECT_ID: casecomp-495718 | |
| REGION: asia-south1 | |
| SERVICE: casecomp-api | |
| IMAGE: gcr.io/casecomp-495718/casecomp-api | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: google-github-actions/auth@v3 | |
| with: | |
| workload_identity_provider: projects/129850122606/locations/global/workloadIdentityPools/github-pool/providers/github-provider | |
| service_account: casecomp-deploy@casecomp-495718.iam.gserviceaccount.com | |
| - uses: google-github-actions/setup-gcloud@v3 | |
| - name: Build and push | |
| run: | | |
| BUILD_ID=$(gcloud builds submit \ | |
| --config=cloudbuild.yml \ | |
| --project ${{ env.PROJECT_ID }} \ | |
| --async \ | |
| --format='value(id)' .) | |
| echo "Waiting for build $BUILD_ID..." | |
| while true; do | |
| STATUS=$(gcloud builds describe $BUILD_ID --project ${{ env.PROJECT_ID }} --format='value(status)' 2>/dev/null) | |
| echo " status: $STATUS" | |
| case "$STATUS" in | |
| SUCCESS) break ;; | |
| FAILURE|TIMEOUT|CANCELLED|INTERNAL_ERROR) echo "Build failed: $STATUS"; exit 1 ;; | |
| *) sleep 15 ;; | |
| esac | |
| done | |
| - name: Deploy to Cloud Run | |
| run: | | |
| gcloud run deploy ${{ env.SERVICE }} \ | |
| --image ${{ env.IMAGE }} \ | |
| --region ${{ env.REGION }} \ | |
| --project ${{ env.PROJECT_ID }} \ | |
| --port 3000 \ | |
| --allow-unauthenticated |