Skip to content

Commit 799103b

Browse files
authored
Delete previous comments of View the CircleCI Test Summary (#42725)
fix Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
1 parent 745ad8c commit 799103b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

.github/workflows/circleci-failure-summary-comment.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,40 @@ jobs:
173173
print(f"Uploaded {folder_path} to {dataset_id}")
174174
EOF
175175
176+
- name: Delete existing CircleCI summary comments
177+
if: steps.circleci.outputs.artifact_found == 'true'
178+
env:
179+
PR_NUMBER: ${{ github.event.pull_request.number }}
180+
uses: actions/github-script@v7
181+
with:
182+
script: |
183+
const PR_NUMBER = parseInt(process.env.PR_NUMBER, 10);
184+
185+
// Get all comments on the PR
186+
const { data: comments } = await github.rest.issues.listComments({
187+
owner: context.repo.owner,
188+
repo: context.repo.repo,
189+
issue_number: PR_NUMBER
190+
});
191+
192+
// Find existing bot comments that start with "View the CircleCI Test Summary for this PR:"
193+
const existingComments = comments.filter(comment =>
194+
comment.user.login === 'github-actions[bot]' &&
195+
comment.body.startsWith('View the CircleCI Test Summary for this PR:')
196+
);
197+
198+
// Delete all matching comments
199+
for (const comment of existingComments) {
200+
console.log(`Deleting comment #${comment.id}`);
201+
await github.rest.issues.deleteComment({
202+
owner: context.repo.owner,
203+
repo: context.repo.repo,
204+
comment_id: comment.id
205+
});
206+
}
207+
208+
console.log(`Deleted ${existingComments.length} old CircleCI summary comment(s)`);
209+
176210
- name: Post comment with helper link
177211
if: steps.circleci.outputs.artifact_found == 'true'
178212
env:

0 commit comments

Comments
 (0)