This repository was archived by the owner on Jul 9, 2026. It is now read-only.
fix: use correct model_id field on TaxBenefitModelVersion #178
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: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "src/**" | |
| - "docs/**" | |
| - ".github/workflows/deploy.yml" | |
| - "terraform/**" | |
| - "Dockerfile" | |
| - "pyproject.toml" | |
| - "uv.lock" | |
| 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 | |
| env: | |
| IMAGE_URL: ${{ vars.GCP_REGION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }} | |
| 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: Configure Docker for Artifact Registry | |
| run: gcloud auth configure-docker ${{ vars.GCP_REGION }}-docker.pkg.dev | |
| - name: Build and push Docker image | |
| run: | | |
| docker build -t $IMAGE_URL:${{ github.sha }} . | |
| docker tag $IMAGE_URL:${{ github.sha }} $IMAGE_URL:latest | |
| docker push $IMAGE_URL:${{ github.sha }} | |
| docker push $IMAGE_URL:latest | |
| - 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 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 | |
| TF_VAR_modal_token_id: ${{ secrets.MODAL_TOKEN_ID }} | |
| TF_VAR_modal_token_secret: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| run: terraform apply -auto-approve | |
| - name: Deploy API to Cloud Run | |
| run: | | |
| gcloud run services update ${{ vars.API_SERVICE_NAME }} \ | |
| --region=${{ vars.GCP_REGION }} \ | |
| --image=$IMAGE_URL:${{ github.sha }} | |
| - name: Get API URL | |
| run: | | |
| API_URL=$(gcloud run services describe ${{ vars.API_SERVICE_NAME }} \ | |
| --region=${{ vars.GCP_REGION }} \ | |
| --format='value(status.url)') | |
| echo "API: $API_URL" | |
| echo "Health: $API_URL/health" | |
| echo "Docs: $API_URL/docs" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Setup Python | |
| run: uv python install 3.13 | |
| - name: Sync dependencies | |
| run: uv sync | |
| - name: Sync Modal secrets from GitHub | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| run: | | |
| echo "Syncing Modal secrets from GitHub..." | |
| uv run modal secret create policyengine-db \ | |
| "DATABASE_URL=${{ secrets.SUPABASE_DB_URL }}" \ | |
| "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" \ | |
| "SUPABASE_KEY=${{ secrets.SUPABASE_KEY }}" \ | |
| --force | |
| uv run modal secret create policyengine-logfire \ | |
| "LOGFIRE_TOKEN=${{ secrets.LOGFIRE_TOKEN }}" \ | |
| --force | |
| echo "Modal secrets synced" | |
| - name: Deploy Modal functions | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| run: | | |
| uv run modal deploy src/policyengine_api/modal_app.py | |
| uv run modal deploy src/policyengine_api/agent_sandbox.py | |
| - name: Validate Modal secrets | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| run: | | |
| echo "Validating Modal secrets..." | |
| result=$(uv run python -c " | |
| import modal | |
| f = modal.Function.from_name('policyengine', 'validate_secrets') | |
| result = f.remote() | |
| import json | |
| print(json.dumps(result)) | |
| ") | |
| echo "$result" | |
| if echo "$result" | grep -q '"status": "error"'; then | |
| echo "::error::Modal secrets validation failed" | |
| exit 1 | |
| fi | |
| echo "Modal secrets validated" |