From 1aef063c8fc26d2e29ecd463f9aad40b85d33dcf Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Wed, 17 Dec 2025 23:32:42 +0400 Subject: [PATCH 1/4] fix: Modify workflows to directly handle Vercel deployment --- .github/workflows/pr.yaml | 69 ++++++++++++++++++++++++++++---- .github/workflows/push.yaml | 78 +++++++++++++++++++++---------------- .gitignore | 1 + 3 files changed, 106 insertions(+), 42 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 6a41b011e..b14e5aef7 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -6,6 +6,10 @@ on: - main - master +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + jobs: lint: name: Lint and format @@ -89,9 +93,12 @@ jobs: working-directory: ./app run: npm test - build: - name: Build + preview: + name: Preview Deploy runs-on: ubuntu-latest + environment: + name: preview + url: ${{ steps.deploy.outputs.url }} steps: - name: Check out repository @@ -100,16 +107,62 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: '24' + node-version: '22' cache: 'npm' cache-dependency-path: package-lock.json - name: Install dependencies run: npm ci - - name: Build design system - run: npm run design-system:build + - name: Install Vercel CLI + run: npm install -g vercel - - name: Build application - working-directory: ./app - run: npm run build + - name: Pull Vercel environment + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + + - name: Create GitHub deployment + uses: chrnorm/deployment-action@v2 + id: deployment + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment: preview + ref: ${{ github.head_ref }} + + - name: Deploy Preview + id: deploy + run: | + url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}) + echo "url=$url" >> $GITHUB_OUTPUT + + - name: Update deployment status + if: always() + uses: chrnorm/deployment-status@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + deployment-id: ${{ steps.deployment.outputs.deployment_id }} + state: ${{ job.status == 'success' && 'success' || 'failure' }} + environment-url: ${{ steps.deploy.outputs.url }} + + - name: Find existing comment + uses: peter-evans/find-comment@v3 + id: find-comment + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Preview deployed + + - name: Create or update comment + uses: peter-evans/create-or-update-comment@v4 + with: + comment-id: ${{ steps.find-comment.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + edit-mode: replace + body: | + ✅ **Preview deployed!** + + 🔗 ${{ steps.deploy.outputs.url }} + + _Commit: ${{ github.event.pull_request.head.sha }}_ diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 66c5b29cc..d738a6a78 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -1,56 +1,66 @@ -name: Push +name: Deploy Production on: push: - branches: [main] + branches: [master] workflow_dispatch: -permissions: - contents: read - pages: write - id-token: write +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} concurrency: - group: "pages" + group: production-deploy cancel-in-progress: false jobs: - build: + deploy: + name: Deploy to Vercel runs-on: ubuntu-latest + environment: + name: production + url: ${{ steps.deploy.outputs.url }} + steps: - name: Checkout uses: actions/checkout@v4 - + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '22' cache: 'npm' - cache-dependency-path: app/package-lock.json - + - name: Install dependencies - run: cd app && npm ci - + run: npm ci + + - name: Install Vercel CLI + run: npm install -g vercel + + - name: Pull Vercel environment + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + - name: Build - run: cd app && npm run build-with-types - env: - BASE_URL: /${{ github.event.repository.name }}/ - - - name: Setup Pages - uses: actions/configure-pages@v5 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: ./app/dist + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages + - name: Create GitHub deployment + uses: chrnorm/deployment-action@v2 id: deployment - uses: actions/deploy-pages@v4 \ No newline at end of file + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment: production + + - name: Deploy to Vercel + id: deploy + run: | + url=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}) + echo "url=$url" >> $GITHUB_OUTPUT + + - name: Update deployment status + if: always() + uses: chrnorm/deployment-status@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + deployment-id: ${{ steps.deployment.outputs.deployment_id }} + state: ${{ job.status == 'success' && 'success' || 'failure' }} + environment-url: ${{ steps.deploy.outputs.url }} diff --git a/.gitignore b/.gitignore index 6a2198fc7..084f40180 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,4 @@ venv/ .venv .vercel .turbo +.env*.local From b6ec02577326a84bb373e6d7e9619289d181fcbd Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Wed, 17 Dec 2025 23:39:03 +0400 Subject: [PATCH 2/4] fix: Minor fixes to workflow --- .github/workflows/pr.yaml | 78 +++++++++++++++++++++++++++---------- .github/workflows/push.yaml | 67 ++++++++++++++++++++++++++++--- 2 files changed, 120 insertions(+), 25 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index b14e5aef7..6cf3367ee 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -8,7 +8,6 @@ on: env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} jobs: lint: @@ -93,12 +92,14 @@ jobs: working-directory: ./app run: npm test - preview: - name: Preview Deploy + preview-website: + name: Preview Website runs-on: ubuntu-latest environment: - name: preview + name: preview-website url: ${{ steps.deploy.outputs.url }} + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_WEBSITE_PROJECT_ID }} steps: - name: Check out repository @@ -128,7 +129,7 @@ jobs: id: deployment with: token: ${{ secrets.GITHUB_TOKEN }} - environment: preview + environment: preview-website ref: ${{ github.head_ref }} - name: Deploy Preview @@ -146,23 +147,60 @@ jobs: state: ${{ job.status == 'success' && 'success' || 'failure' }} environment-url: ${{ steps.deploy.outputs.url }} - - name: Find existing comment - uses: peter-evans/find-comment@v3 - id: find-comment + preview-calculator: + name: Preview Calculator + runs-on: ubuntu-latest + environment: + name: preview-calculator + url: ${{ steps.deploy.outputs.url }} + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_CALCULATOR_PROJECT_ID }} + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: Preview deployed + node-version: '22' + cache: 'npm' + cache-dependency-path: package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Install Vercel CLI + run: npm install -g vercel + + - name: Pull Vercel environment + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + working-directory: ./calculator - - name: Create or update comment - uses: peter-evans/create-or-update-comment@v4 + - name: Build + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + working-directory: ./calculator + + - name: Create GitHub deployment + uses: chrnorm/deployment-action@v2 + id: deployment with: - comment-id: ${{ steps.find-comment.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - edit-mode: replace - body: | - ✅ **Preview deployed!** + token: ${{ secrets.GITHUB_TOKEN }} + environment: preview-calculator + ref: ${{ github.head_ref }} - 🔗 ${{ steps.deploy.outputs.url }} + - name: Deploy Preview + id: deploy + run: | + url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}) + echo "url=$url" >> $GITHUB_OUTPUT + working-directory: ./calculator - _Commit: ${{ github.event.pull_request.head.sha }}_ + - name: Update deployment status + if: always() + uses: chrnorm/deployment-status@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + deployment-id: ${{ steps.deployment.outputs.deployment_id }} + state: ${{ job.status == 'success' && 'success' || 'failure' }} + environment-url: ${{ steps.deploy.outputs.url }} diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index d738a6a78..45335a8fe 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -7,19 +7,20 @@ on: env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} concurrency: group: production-deploy cancel-in-progress: false jobs: - deploy: - name: Deploy to Vercel + deploy-website: + name: Deploy Website runs-on: ubuntu-latest environment: - name: production + name: production-website url: ${{ steps.deploy.outputs.url }} + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_WEBSITE_PROJECT_ID }} steps: - name: Checkout @@ -48,7 +49,7 @@ jobs: id: deployment with: token: ${{ secrets.GITHUB_TOKEN }} - environment: production + environment: production-website - name: Deploy to Vercel id: deploy @@ -64,3 +65,59 @@ jobs: deployment-id: ${{ steps.deployment.outputs.deployment_id }} state: ${{ job.status == 'success' && 'success' || 'failure' }} environment-url: ${{ steps.deploy.outputs.url }} + + deploy-calculator: + name: Deploy Calculator + runs-on: ubuntu-latest + environment: + name: production-calculator + url: ${{ steps.deploy.outputs.url }} + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_CALCULATOR_PROJECT_ID }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Install Vercel CLI + run: npm install -g vercel + + - name: Pull Vercel environment + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + working-directory: ./calculator + + - name: Build + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + working-directory: ./calculator + + - name: Create GitHub deployment + uses: chrnorm/deployment-action@v2 + id: deployment + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment: production-calculator + + - name: Deploy to Vercel + id: deploy + run: | + url=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}) + echo "url=$url" >> $GITHUB_OUTPUT + working-directory: ./calculator + + - name: Update deployment status + if: always() + uses: chrnorm/deployment-status@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + deployment-id: ${{ steps.deployment.outputs.deployment_id }} + state: ${{ job.status == 'success' && 'success' || 'failure' }} + environment-url: ${{ steps.deploy.outputs.url }} From 03db8733ff85015be24762bf69dcd79d0816688b Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 18 Dec 2025 00:09:41 +0400 Subject: [PATCH 3/4] fix: Deploy all three Vercel projects as part of GH --- .github/workflows/pr.yaml | 60 +++++++++++++++++++++++++++++++++++++ .github/workflows/push.yaml | 57 +++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 6cf3367ee..c1d7583b9 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -6,6 +6,11 @@ on: - main - master +permissions: + contents: read + deployments: write + pull-requests: read + env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} @@ -92,6 +97,61 @@ jobs: working-directory: ./app run: npm test + preview-app-v2: + name: Preview App V2 + runs-on: ubuntu-latest + environment: + name: preview-app-v2 + url: ${{ steps.deploy.outputs.url }} + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_APP_V2_PROJECT_ID }} + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'npm' + cache-dependency-path: package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Install Vercel CLI + run: npm install -g vercel + + - name: Pull Vercel environment + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + + - name: Create GitHub deployment + uses: chrnorm/deployment-action@v2 + id: deployment + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment: preview-app-v2 + ref: ${{ github.head_ref }} + + - name: Deploy Preview + id: deploy + run: | + url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}) + echo "url=$url" >> $GITHUB_OUTPUT + + - name: Update deployment status + if: always() + uses: chrnorm/deployment-status@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + deployment-id: ${{ steps.deployment.outputs.deployment_id }} + state: ${{ job.status == 'success' && 'success' || 'failure' }} + environment-url: ${{ steps.deploy.outputs.url }} + preview-website: name: Preview Website runs-on: ubuntu-latest diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 45335a8fe..2421a1109 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -5,6 +5,10 @@ on: branches: [master] workflow_dispatch: +permissions: + contents: read + deployments: write + env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} @@ -13,6 +17,59 @@ concurrency: cancel-in-progress: false jobs: + deploy-app-v2: + name: Deploy App V2 + runs-on: ubuntu-latest + environment: + name: production-app-v2 + url: ${{ steps.deploy.outputs.url }} + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_APP_V2_PROJECT_ID }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Install Vercel CLI + run: npm install -g vercel + + - name: Pull Vercel environment + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + + - name: Create GitHub deployment + uses: chrnorm/deployment-action@v2 + id: deployment + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment: production-app-v2 + + - name: Deploy to Vercel + id: deploy + run: | + url=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}) + echo "url=$url" >> $GITHUB_OUTPUT + + - name: Update deployment status + if: always() + uses: chrnorm/deployment-status@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + deployment-id: ${{ steps.deployment.outputs.deployment_id }} + state: ${{ job.status == 'success' && 'success' || 'failure' }} + environment-url: ${{ steps.deploy.outputs.url }} + deploy-website: name: Deploy Website runs-on: ubuntu-latest From b9ab34458fb1345cb9c79a841cc50687be78c30b Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 18 Dec 2025 00:14:28 +0400 Subject: [PATCH 4/4] fix: Properly add back checks on deploy, make deploy dependent on checks --- .github/workflows/push.yaml | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 2421a1109..da5fb626c 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -17,8 +17,91 @@ concurrency: cancel-in-progress: false jobs: + lint: + name: Lint and format + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '24' + cache: 'npm' + cache-dependency-path: package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Build design system + run: npm run design-system:build + + - name: Check formatting with Prettier + working-directory: ./app + run: npm run prettier + + - name: Run ESLint + working-directory: ./app + run: npm run eslint + + typecheck: + name: Type checking + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '24' + cache: 'npm' + cache-dependency-path: package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Build design system + run: npm run design-system:build + + - name: Run TypeScript type checks + working-directory: ./app + run: npm run typecheck + + test: + name: Tests + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '24' + cache: 'npm' + cache-dependency-path: package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Build design system + run: npm run design-system:build + + - name: Run design system tests + run: npm test --workspace=@policyengine/design-system + + - name: Run app tests + working-directory: ./app + run: npm test + deploy-app-v2: name: Deploy App V2 + needs: [lint, typecheck, test] runs-on: ubuntu-latest environment: name: production-app-v2 @@ -72,6 +155,7 @@ jobs: deploy-website: name: Deploy Website + needs: [lint, typecheck, test] runs-on: ubuntu-latest environment: name: production-website @@ -125,6 +209,7 @@ jobs: deploy-calculator: name: Deploy Calculator + needs: [lint, typecheck, test] runs-on: ubuntu-latest environment: name: production-calculator