Skip to content

Commit bb99bb8

Browse files
authored
Delete old migration PR comments (#792)
### Summary & Motivation The workflow now deletes all previous migration information comments from the pull request before posting a new migration info comment. This prevents repeated migration comments from accumulating on the same PR when multiple pushes occur. ### Checklist - [x] I have added tests, or done manual regression tests - [x] I have updated the documentation, if necessary
2 parents 4afdf35 + 3adbd09 commit bb99bb8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

.github/workflows/_migrate-database.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,28 @@ jobs:
190190
with:
191191
github-token: ${{ secrets.GITHUB_TOKEN }}
192192
script: |
193-
github.rest.issues.createComment({
193+
// Delete previous migration info comments
194+
const comments = await github.rest.issues.listComments({
195+
issue_number: context.issue.number,
196+
owner: context.repo.owner,
197+
repo: context.repo.repo,
198+
per_page: 100
199+
});
200+
201+
const MIGRATION_HEADER = '## Approve Database Migration';
202+
203+
for (const comment of comments.data) {
204+
if (comment.body && comment.body.startsWith(MIGRATION_HEADER)) {
205+
await github.rest.issues.deleteComment({
206+
owner: context.repo.owner,
207+
repo: context.repo.repo,
208+
comment_id: comment.id
209+
});
210+
}
211+
}
212+
213+
// Add the new migration info comment
214+
await github.rest.issues.createComment({
194215
issue_number: context.issue.number,
195216
owner: context.repo.owner,
196217
repo: context.repo.repo,

0 commit comments

Comments
 (0)