Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
name: Vercel Preview Deployment

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
workflow_dispatch:
# Uncomment when vercel project setup
# push:
# branches-ignore:
# - main

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

Expand All @@ -29,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"
Loading