Skip to content

Commit 00fc134

Browse files
authored
Merge pull request #1970 from dscho/mark-outdated-link-checker-comments
ci(link-check): mark outdated link check comments as such
2 parents 3368db3 + 64e26f8 commit 00fc134

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/actions/deploy-to-github-pages/action.yml

+39
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,45 @@ runs:
222222
await github.rest.issues.createComment({ ...req, body })
223223
if ('${{ steps.lychee.outputs.exit_code }}' === '0') {
224224
await github.rest.issues.update({ ...req, state: 'closed' })
225+
} else {
226+
// minimize outdated comments, if any
227+
const query = `query ($owner: String!, $repo: String!, $issue_number: Int!) {
228+
repository(owner: $owner, name: $repo) {
229+
issue(number: $issue_number) {
230+
comments(first: 100) {
231+
nodes {
232+
id
233+
isMinimized
234+
minimizedReason
235+
body
236+
author {
237+
login
238+
}
239+
}
240+
}
241+
}
242+
}
243+
}`
244+
const commentIds = (await github.graphql(query, req)).repository.issue.comments.nodes
245+
commentIds.pop() // leave the just-created comment alone
246+
const markOutdatedCommentMutation = `mutation ($id: ID!, $classifier: ReportedContentClassifiers!) {
247+
minimizeComment(input: { subjectId: $id, classifier: $classifier }) {
248+
clientMutationId
249+
minimizedComment {
250+
isMinimized
251+
minimizedReason
252+
viewerCanMinimize
253+
}
254+
}
255+
}`
256+
for (const outdatedComment of commentIds.filter(
257+
comment => comment.author.login === 'github-actions' && comment.isMinimized === false
258+
)) {
259+
await github.graphql(markOutdatedCommentMutation, {
260+
id: outdatedComment.id,
261+
classifier: 'OUTDATED',
262+
})
263+
}
225264
}
226265
}
227266

0 commit comments

Comments
 (0)