-
Notifications
You must be signed in to change notification settings - Fork 1
65 lines (56 loc) · 1.76 KB
/
deploy.yml
File metadata and controls
65 lines (56 loc) · 1.76 KB
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
name: Deploy to Vercel
on:
push:
branches:
- main
pull_request:
concurrency:
group: vercel-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
deploy:
runs-on: ubuntu-latest
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Deploy Preview (PR)
if: github.event_name == 'pull_request'
id: deploy_preview
run: |
bash scripts/deploy-vercel.sh preview --output .vercel/last-deployment-url.txt | tee .vercel/preview-url.txt
echo "url=$(tail -n1 .vercel/preview-url.txt | tr -d '\n')" >> $GITHUB_OUTPUT
- name: Comment Preview URL on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const url = process.env.url;
const body = `🚀 Preview deployed: ${url}`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});
env:
url: ${{ steps.deploy_preview.outputs.url }}
- name: Deploy Production (main push)
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
bash scripts/deploy-vercel.sh production