From 64e26f8b5c3122229f5819e5161ff430e46f0faf Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 6 Mar 2025 12:49:12 +0100 Subject: [PATCH] ci(link-check): mark outdated link check comments as such In particular with long-running issues where links are broken for weeks (and over the course of dozens of git-scm.com deployments), while it is nice that the link checker adds the most recent "verdict", the previous ones are no longer _that_ interesting. Let's hide them. Signed-off-by: Johannes Schindelin --- .../actions/deploy-to-github-pages/action.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.github/actions/deploy-to-github-pages/action.yml b/.github/actions/deploy-to-github-pages/action.yml index 146e6af0f7..231894a6e5 100644 --- a/.github/actions/deploy-to-github-pages/action.yml +++ b/.github/actions/deploy-to-github-pages/action.yml @@ -222,6 +222,45 @@ runs: await github.rest.issues.createComment({ ...req, body }) if ('${{ steps.lychee.outputs.exit_code }}' === '0') { await github.rest.issues.update({ ...req, state: 'closed' }) + } else { + // minimize outdated comments, if any + const query = `query ($owner: String!, $repo: String!, $issue_number: Int!) { + repository(owner: $owner, name: $repo) { + issue(number: $issue_number) { + comments(first: 100) { + nodes { + id + isMinimized + minimizedReason + body + author { + login + } + } + } + } + } + }` + const commentIds = (await github.graphql(query, req)).repository.issue.comments.nodes + commentIds.pop() // leave the just-created comment alone + const markOutdatedCommentMutation = `mutation ($id: ID!, $classifier: ReportedContentClassifiers!) { + minimizeComment(input: { subjectId: $id, classifier: $classifier }) { + clientMutationId + minimizedComment { + isMinimized + minimizedReason + viewerCanMinimize + } + } + }` + for (const outdatedComment of commentIds.filter( + comment => comment.author.login === 'github-actions' && comment.isMinimized === false + )) { + await github.graphql(markOutdatedCommentMutation, { + id: outdatedComment.id, + classifier: 'OUTDATED', + }) + } } }