refactor(web): migrate remaining env variables to T3 Env #22
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 Web | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "apps/web/**" | |
| - ".github/workflows/deploy-web.yml" | |
| workflow_dispatch: | |
| env: | |
| PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} | |
| REGION: ${{ vars.GCP_REGION }} | |
| SERVICE_NAME: fullstack-starter-web | |
| WORKLOAD_IDENTITY_PROVIDER: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }} | |
| SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }} | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: apps/web | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| cache: "pnpm" | |
| cache-dependency-path: apps/web/pnpm-lock.yaml | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run linter | |
| run: pnpm lint | |
| - name: Run type check | |
| run: pnpm typecheck | |
| - name: Run tests | |
| run: pnpm test | |
| 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/web:${{ github.sha }}" | |
| docker build -t $IMAGE apps/web \ | |
| --build-arg NEXT_PUBLIC_API_URL=${{ vars.API_URL }} | |
| 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=10 | |
| --cpu=1 | |
| --memory=512Mi | |
| --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" >> $GITHUB_STEP_SUMMARY |