|
5 | 5 | types: [opened, synchronize, reopened, closed]
|
6 | 6 | paths:
|
7 | 7 | - "docs/**"
|
| 8 | + - ".github/workflows/docs.yaml" |
8 | 9 | - ".github/workflows/docs-*.yaml"
|
9 | 10 | branches:
|
10 | 11 | - master
|
@@ -61,14 +62,37 @@ jobs:
|
61 | 62 | with:
|
62 | 63 | script: |
|
63 | 64 | const previewUrl = `https://pr-${context.payload.pull_request.number}.docs-lakefs-preview.io/`;
|
64 |
| - github.rest.issues.createComment({ |
| 65 | + const commentBody = `📚 Documentation preview at ${previewUrl}`; |
| 66 | +
|
| 67 | + // Check if a preview comment already exists |
| 68 | + const { data: comments } = await github.rest.issues.listComments({ |
65 | 69 | issue_number: context.payload.pull_request.number,
|
66 | 70 | owner: context.repo.owner,
|
67 | 71 | repo: context.repo.repo,
|
68 |
| - body: `📚 Documentation preview at ${previewUrl}`, |
69 |
| - event: 'COMMENT' |
70 | 72 | });
|
71 | 73 |
|
| 74 | + const existingComment = comments.find(comment => |
| 75 | + comment.body.includes(' Documentation preview at ') && comment.user.type === 'Bot' |
| 76 | + ); |
| 77 | +
|
| 78 | + if (existingComment) { |
| 79 | + await github.rest.issues.updateComment({ |
| 80 | + comment_id: existingComment.id, |
| 81 | + owner: context.repo.owner, |
| 82 | + repo: context.repo.repo, |
| 83 | + body: commentBody |
| 84 | + }); |
| 85 | + core.info('Updated existing preview comment'); |
| 86 | + } else { |
| 87 | + await github.rest.issues.createComment({ |
| 88 | + issue_number: context.payload.pull_request.number, |
| 89 | + owner: context.repo.owner, |
| 90 | + repo: context.repo.repo, |
| 91 | + body: commentBody |
| 92 | + }); |
| 93 | + core.info('Created new preview comment'); |
| 94 | + } |
| 95 | +
|
72 | 96 | - name: Check links
|
73 | 97 | id: lychee
|
74 | 98 | uses: lycheeverse/[email protected]
|
|
0 commit comments