Skip to content

Commit e21d0ae

Browse files
authored
docs: update or create docs preview comment (#9189)
1 parent b0d45b0 commit e21d0ae

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

.github/workflows/docs-pr.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
types: [opened, synchronize, reopened, closed]
66
paths:
77
- "docs/**"
8+
- ".github/workflows/docs.yaml"
89
- ".github/workflows/docs-*.yaml"
910
branches:
1011
- master
@@ -61,14 +62,37 @@ jobs:
6162
with:
6263
script: |
6364
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({
6569
issue_number: context.payload.pull_request.number,
6670
owner: context.repo.owner,
6771
repo: context.repo.repo,
68-
body: `📚 Documentation preview at ${previewUrl}`,
69-
event: 'COMMENT'
7072
});
7173
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+
7296
- name: Check links
7397
id: lychee
7498
uses: lycheeverse/[email protected]

.github/workflows/docs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- master
77
paths:
88
- "docs/**"
9+
- ".github/workflows/docs.yaml"
910
- ".github/workflows/docs-*.yaml"
1011
release:
1112
types: [published]

0 commit comments

Comments
 (0)