fix(worker): allow empty test suite to pass in pre-push hook #6
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 Worker | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "apps/worker/**" | |
| - ".github/workflows/deploy-worker.yml" | |
| workflow_dispatch: | |
| env: | |
| PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} | |
| REGION: ${{ vars.GCP_REGION }} | |
| SERVICE_NAME: fullstack-starter-worker | |
| WORKLOAD_IDENTITY_PROVIDER: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }} | |
| SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }} | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: apps/worker | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Install dependencies | |
| run: uv sync --frozen | |
| - name: Run linter | |
| run: uv run ruff check . | |
| - name: Run type checker | |
| run: uv run pyright | |
| - name: Run tests | |
| run: uv run pytest | |
| build-and-deploy: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }} | |
| service_account: ${{ env.SERVICE_ACCOUNT }} | |
| - name: Set up Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v2 | |
| - name: Configure Docker | |
| run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev | |
| - name: Build and push image | |
| run: | | |
| IMAGE="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/fullstack-starter-images/worker:${{ github.sha }}" | |
| docker build -t $IMAGE apps/worker | |
| docker push $IMAGE | |
| echo "IMAGE=$IMAGE" >> $GITHUB_ENV | |
| - name: Deploy to Cloud Run | |
| uses: google-github-actions/deploy-cloudrun@v2 | |
| with: | |
| service: ${{ env.SERVICE_NAME }} | |
| region: ${{ env.REGION }} | |
| image: ${{ env.IMAGE }} | |
| flags: | | |
| --min-instances=0 | |
| --max-instances=5 | |
| --cpu=1 | |
| --memory=512Mi | |
| --ingress=internal | |
| --no-allow-unauthenticated | |
| - name: Show deployment URL | |
| run: | | |
| URL=$(gcloud run services describe ${{ env.SERVICE_NAME }} --region=${{ env.REGION }} --format='value(status.url)') | |
| echo "### Deployed to: $URL (internal only)" >> $GITHUB_STEP_SUMMARY |