-
Notifications
You must be signed in to change notification settings - Fork 409
51 lines (48 loc) · 1.69 KB
/
docs-preview-deploy.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
name: Docs Preview Deploy
on: pull_request
jobs:
deploy:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- uses: actions/github-script@v7
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
with:
script: |
const res = await fetch(`https://api.vercel.com/v13/deployments?teamId=${process.env.VERCEL_TEAM_ID}`, {
"body": JSON.stringify({
name: "edgedb-docs",
gitSource: {
type: "github",
org: "edgedb",
repo: "edgedb.com",
ref: "docs-preview",
},
projectSettings: {
buildCommand:
`EDGEDB_REPO_BRANCH=${process.env.GITHUB_HEAD_REF} yarn vercel-build`,
},
}),
"headers": {
"Authorization": `Bearer ${process.env.VERCEL_TOKEN}`,
"Content-Type": "application/json",
},
"method": "post"
});
if (res.ok) {
const deployment = await res.json();
console.log(deployment.url);
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Deployed docs preview: <https://${deployment.url}>`,
});
} else {
throw new Error(
`vercel create deployment api request failed: ${res.status} ${res.statusText}`
);
}