Add setup-gcp.sh to provision WIF + service account in one step #1
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 to Cloud Run | |
| on: | |
| push: | |
| branches: [deploy-github] | |
| workflow_dispatch: | |
| env: | |
| PROJECT_ID: fullstackpro-python | |
| REGION: us-central1 | |
| SERVICE: fastapi-hello | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write # required for Workload Identity Federation | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| workload_identity_provider: ${{ secrets.GCP_WIF_PROVIDER }} | |
| service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} | |
| - name: Set up gcloud | |
| uses: google-github-actions/setup-gcloud@v2 | |
| - name: Deploy to Cloud Run | |
| run: | | |
| gcloud run deploy "$SERVICE" \ | |
| --source . \ | |
| --project "$PROJECT_ID" \ | |
| --region "$REGION" \ | |
| --platform managed \ | |
| --allow-unauthenticated \ | |
| --quiet | |
| - name: Show service URL | |
| run: | | |
| gcloud run services describe "$SERVICE" \ | |
| --project "$PROJECT_ID" \ | |
| --region "$REGION" \ | |
| --format="value(status.url)" |