-
Notifications
You must be signed in to change notification settings - Fork 6
59 lines (50 loc) · 1.58 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
name: Deploy to Preview
env:
VERCEL_ORG_ID: ${{ secrets.ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.PROJECT_ID }}
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
CI:
uses: './.github/workflows/ci.yml'
deploy:
needs: CI
runs-on: ubuntu-latest
environment: Preview
outputs:
deploymentUrl: ${{ steps.deploy.outputs.deploymentUrl }}
steps:
- uses: actions/checkout@v4
- name: install pnpm
uses: pnpm/action-setup@v3
- name: install Vercel CLI
run: pnpm install --global vercel@latest
- name: pull Vercel environment information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: build project artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: deploy project artifacts to Vercel
id: deploy
run: |
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > deploy.log
echo "deploymentUrl=$(cat deploy.log)" >> $GITHUB_OUTPUT
comment:
needs: deploy
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: comment URL to PR
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Deployed at ${{ env.DEPLOYMENT_URL }}"
})
env:
DEPLOYMENT_URL: ${{ needs.deploy.outputs.deploymentUrl }}