-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (61 loc) · 2.49 KB
/
preview.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Preview
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
on:
pull_request:
jobs:
preview:
name: Deploy to Vercel
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Get Next Version
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: patch
default_prerelease_bump: prerelease
release_branches: master
pre_release_branches: staging
append_to_pre_release_tag: prerelease
dry_run: true
- name: Setup Vercel
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_SCOPE}}
- name: Setup Environment Variables
run: |
vercel env pull .env.local --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
echo API_KEY=${{ secrets.VERCEL_PREVIEW_API_KEY }} >> .env.local
echo PERSCOM_ID=${{ secrets.VERCEL_PREVIEW_PERSCOM_ID }} >> .env.local
echo SENTRY_RELEASE=${{ steps.tag_version.outputs.new_tag }}-preview.$(git rev-parse --short "$GITHUB_SHA") >> .env.local
echo NEXT_PUBLIC_WIDGET_VERSION=${{ steps.tag_version.outputs.new_tag }}-preview.$(git rev-parse --short "$GITHUB_SHA") >> .env.local
- name: Build Widget
run: npm run build:widget
env:
WIDGET_URL: https://staging.widget.perscom.io
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: echo "DEPLOYMENT_URL=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})" >> $GITHUB_ENV
- name: Add PR Comment
uses: mshick/add-pr-comment@v2
with:
message: |
**Vercel Deployment**
✅ Deployment Preview URL: [${{ env.DEPLOYMENT_URL }}](${{ env.DEPLOYMENT_URL }})