Skip to content

Commit 2d5592d

Browse files
committed
Hide all artifact-size comments if the size increase is acknowledged
1 parent d94885a commit 2d5592d

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

.github/workflows/codebuild-ci.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,22 @@ jobs:
146146
uses: actions/github-script@v7
147147
with:
148148
script: |
149+
const fs = require('node:fs')
150+
151+
const prNumber = context.issue.number ?? process.env.SDK_PR
152+
153+
const prInfo = await github.rest.pulls.get({
154+
owner: context.repo.owner,
155+
repo: context.repo.repo,
156+
pull_number: prNumber
157+
})
158+
159+
const hasAcknowledgeLabel = prInfo.data.labels.some(label => label.name === 'acknowledge-artifact-size-increase')
160+
149161
const getComments =
150162
`query {
151163
repository(owner:"${context.repo.owner}", name:"${context.repo.repo}"){
152-
pullRequest(number: ${context.issue.number ?? process.env.SDK_PR}) {
164+
pullRequest(number: ${prNumber}) {
153165
id
154166
comments(last:100) {
155167
nodes {
@@ -181,17 +193,31 @@ jobs:
181193
)
182194
await Promise.all(mutations)
183195
184-
const fs = require('node:fs')
185196
const comment = fs.readFileSync('build/reports/metrics/artifact-analysis.md', 'utf8')
186197
187198
const writeComment =
188199
`mutation {
189200
addComment(input:{body:"""${comment}""", subjectId:"${response.repository.pullRequest.id}"}){
190-
clientMutationId
201+
commentEdge {
202+
node {
203+
id
204+
}
205+
}
191206
}
192207
}`
193208
194-
await github.graphql(writeComment)
209+
const addCommentResponse = await github.graphql(writeComment)
210+
const newCommentId = addCommentResponse.addComment.commentEdge.node.id
211+
212+
if (hasAcknowledgeLabel) {
213+
await github.graphql(
214+
`mutation {
215+
minimizeComment(input:{subjectId:"${newCommentId}", classifier:ACKNOWLEDGED}){
216+
clientMutationId
217+
}
218+
}`
219+
)
220+
}
195221
196222
- name: Evaluate Result
197223
if: ${{ !contains(github.event.pull_request.labels.*.name, 'acknowledge-artifact-size-increase') }}

0 commit comments

Comments
 (0)