Skip to content

Commit 90e8629

Browse files
authored
Add comment hider back (#5495)
1 parent 901dd52 commit 90e8629

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

.github/workflows/mypy_primer_comment.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,36 @@ jobs:
6969
body
7070
})
7171
72-
# FIXME: comment hider doesn't work from this file
73-
# - uses: kanga333/comment-hider@9141763feccc8da773595675adc567d6616b6e6f
74-
# name: Hide old comments
75-
# with:
76-
# github_token: ${{ secrets.GITHUB_TOKEN }}
77-
# leave_visible: 1
72+
# Based on https://github.com/kanga333/comment-hider/blob/9141763feccc8da773595675adc567d6616b6e6f/src/client.ts
73+
# Can't use kanga333/comment-hider because https://github.com/kanga333/comment-hider/issues/26
74+
- name: Hide old comments
75+
uses: actions/github-script@v3
76+
with:
77+
github-token: ${{secrets.GITHUB_TOKEN}}
78+
script: |
79+
const fs = require('fs')
80+
81+
const response = await github.issues.listComments({
82+
issue_number: fs.readFileSync("pr_number.txt", { encoding: "utf8" }),
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
})
86+
const botCommentIds = response.data
87+
.filter(comment => comment.user.login === 'github-actions[bot]')
88+
.map(comment => comment.node_id)
89+
.slice(0, -1) // skip last comment
90+
91+
for (const id of botCommentIds) {
92+
const resp = await github.graphql(`
93+
mutation {
94+
minimizeComment(input: {classifier: OUTDATED, subjectId: "${id}"}) {
95+
minimizedComment {
96+
isMinimized
97+
}
98+
}
99+
}
100+
`)
101+
if (resp.errors) {
102+
throw new Error(resp.errors)
103+
}
104+
}

0 commit comments

Comments
 (0)