-
Notifications
You must be signed in to change notification settings - Fork 56
52 lines (52 loc) · 1.72 KB
/
ci-pr-docs.yaml
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
name: ci pr docs
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_DOCS_PROJECT_ID }}
on:
pull_request:
paths:
- 'docs/**'
jobs:
deploy:
runs-on: ubuntu-latest
outputs:
url: ${{ steps.deploy.outputs.deployment_url }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install PNPM
uses: pnpm/action-setup@v4
with:
version: 8
- 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: echo "deployment_url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})" >> $GITHUB_OUTPUT
comment:
needs: deploy
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Comment PR with Deployment URL
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const deployment_url = '${{ needs.deploy.outputs.url }}';
const pr_number = context.payload.pull_request.number;
const repository = context.repo.repo;
const owner = context.repo.owner;
github.rest.issues.createComment({
owner: owner,
repo: repository,
issue_number: pr_number,
body: `Docs preview complete 🚀 see it here: ${deployment_url}`
});