From 43bd9fd637434edc9d0c2be040bb975c86783854 Mon Sep 17 00:00:00 2001 From: Precious Oritsedere Date: Wed, 5 Aug 2026 13:54:57 +0100 Subject: [PATCH 1/2] Enable Vercel deploy previews on pull requests --- .github/workflows/CI.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index f6d4b53..998d99a 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -4,10 +4,8 @@ env: VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} on: workflow_dispatch: - # Uncomment when vercel project setup - # push: - # branches-ignore: - # - main + pull_request: + types: [opened, synchronize, reopened] jobs: Deploy-Preview: runs-on: ubuntu-latest From 54593439db46c61389f86a7ec49bc2b7081cf46a Mon Sep 17 00:00:00 2001 From: Precious Oritsedere Date: Wed, 5 Aug 2026 16:05:10 +0100 Subject: [PATCH 2/2] update ci to allow comment for vercel preview --- .github/workflows/CI.yaml | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 998d99a..a7fe5d0 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -1,14 +1,27 @@ name: Vercel Preview Deployment -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + on: workflow_dispatch: pull_request: types: [opened, synchronize, reopened] + +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +concurrency: + group: preview-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: Deploy-Preview: runs-on: ubuntu-latest + if: >- + github.event_name == 'workflow_dispatch' || + github.event.pull_request.head.repo.full_name == github.repository + permissions: + contents: read + pull-requests: write steps: - uses: actions/checkout@v5 @@ -27,4 +40,18 @@ jobs: run: vercel build --token=${{ secrets.VERCEL_TOKEN }} - name: Deploy Project Artifacts to Vercel - run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} + id: deploy + run: | + url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} | tail -n1) + echo "url=$url" >> "$GITHUB_OUTPUT" + + - name: Comment the preview URL on the pull request + if: github.event_name == 'pull_request' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + URL: ${{ steps.deploy.outputs.url }} + run: | + gh pr comment ${{ github.event.pull_request.number }} \ + --repo ${{ github.repository }} \ + --edit-last --create-if-none \ + --body "Preview deployment: $URL"