Shorten service account and VPC connector names #40
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 GCP Cloud Run | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Setup Python | |
| run: uv python install 3.13 | |
| - name: Sync dependencies | |
| run: uv sync --extra dev | |
| - name: Run tests | |
| run: uv run pytest tests/test_models.py -v | |
| deploy: | |
| name: Deploy | |
| runs-on: ubuntu-latest | |
| needs: test | |
| environment: production | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | |
| service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} | |
| - name: Set up Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v2 | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.6.0 | |
| - name: Terraform init | |
| working-directory: ./terraform | |
| run: terraform init | |
| - name: Terraform plan | |
| working-directory: ./terraform | |
| env: | |
| TF_VAR_supabase_url: ${{ secrets.SUPABASE_URL }} | |
| TF_VAR_supabase_key: ${{ secrets.SUPABASE_KEY }} | |
| TF_VAR_supabase_db_url: ${{ secrets.SUPABASE_DB_URL }} | |
| TF_VAR_logfire_token: ${{ secrets.LOGFIRE_TOKEN }} | |
| TF_VAR_logfire_environment: prod | |
| run: terraform plan | |
| - name: Terraform apply | |
| working-directory: ./terraform | |
| env: | |
| TF_VAR_supabase_url: ${{ secrets.SUPABASE_URL }} | |
| TF_VAR_supabase_key: ${{ secrets.SUPABASE_KEY }} | |
| TF_VAR_supabase_db_url: ${{ secrets.SUPABASE_DB_URL }} | |
| TF_VAR_logfire_token: ${{ secrets.LOGFIRE_TOKEN }} | |
| TF_VAR_logfire_environment: prod | |
| run: terraform apply -auto-approve | |
| - name: Configure Docker for Artifact Registry | |
| run: gcloud auth configure-docker ${{ vars.GCP_REGION }}-docker.pkg.dev | |
| - name: Build and push Docker image | |
| env: | |
| IMAGE_URL: ${{ vars.GCP_REGION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }} | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| docker build -t $IMAGE_URL:$IMAGE_TAG . | |
| docker tag $IMAGE_URL:$IMAGE_TAG $IMAGE_URL:latest | |
| docker push $IMAGE_URL:$IMAGE_TAG | |
| docker push $IMAGE_URL:latest | |
| - name: Deploy API to Cloud Run | |
| run: | | |
| gcloud run services update-traffic ${{ vars.API_SERVICE_NAME }} \ | |
| --region=${{ vars.GCP_REGION }} \ | |
| --to-latest | |
| - name: Deploy Worker to Cloud Run | |
| run: | | |
| gcloud run services update-traffic ${{ vars.WORKER_SERVICE_NAME }} \ | |
| --region=${{ vars.GCP_REGION }} \ | |
| --to-latest | |
| - name: Get API URL | |
| run: | | |
| echo "=== API Endpoint ===" | |
| API_URL=$(gcloud run services describe ${{ vars.API_SERVICE_NAME }} \ | |
| --region=${{ vars.GCP_REGION }} \ | |
| --format='value(status.url)') | |
| echo "API is available at: $API_URL" | |
| echo "Health check: $API_URL/health" | |
| echo "Documentation: $API_URL/docs" |