-
Notifications
You must be signed in to change notification settings - Fork 11
63 lines (58 loc) · 1.89 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
name: Preview
on:
pull_request_target:
jobs:
preview:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const { number } = context.issue;
const pr = await github.rest.pulls.get({
owner,
repo,
pull_number: number,
});
const { merge_commit_sha } = pr.data;
const head_sha = pr.data.head.sha;
const link = `https://stackblitz.com/github/mlflow/mlflow-website/tree/${merge_commit_sha}/website`;
const marker = "<!-- PREVIEW -->";
const body = `
${marker}
## Preview for ${head_sha}
- For faster build, the doc pages are not included in the preview.
- Redirects are disabled in the preview.
<a href="${link}" target="_blank">
<img
alt="Open in StackBlitz"
src="https://developer.stackblitz.com/img/open_in_stackblitz.svg"
/>
</a>
`;
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number: number,
});
const comment = comments.find(({ body }) => body.includes(marker));
if (comment) {
await github.rest.issues.updateComment({
comment_id: comment.id,
owner,
repo,
body,
});
} else {
await github.rest.issues.createComment({
issue_number: number,
owner,
repo,
body,
});
}