diff --git a/.github/workflows/codebuild-ci.yml b/.github/workflows/codebuild-ci.yml index 609c81b0340..be9184aa4d7 100644 --- a/.github/workflows/codebuild-ci.yml +++ b/.github/workflows/codebuild-ci.yml @@ -146,10 +146,22 @@ jobs: uses: actions/github-script@v7 with: script: | + const fs = require('node:fs') + + const prNumber = context.issue.number ?? process.env.SDK_PR + + const prInfo = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber + }) + + const hasAcknowledgeLabel = prInfo.data.labels.some(label => label.name === 'acknowledge-artifact-size-increase') + const getComments = `query { repository(owner:"${context.repo.owner}", name:"${context.repo.repo}"){ - pullRequest(number: ${context.issue.number ?? process.env.SDK_PR}) { + pullRequest(number: ${prNumber}) { id comments(last:100) { nodes { @@ -181,17 +193,31 @@ jobs: ) await Promise.all(mutations) - const fs = require('node:fs') const comment = fs.readFileSync('build/reports/metrics/artifact-analysis.md', 'utf8') const writeComment = `mutation { addComment(input:{body:"""${comment}""", subjectId:"${response.repository.pullRequest.id}"}){ - clientMutationId + commentEdge { + node { + id + } + } } }` - await github.graphql(writeComment) + const addCommentResponse = await github.graphql(writeComment) + const newCommentId = addCommentResponse.addComment.commentEdge.node.id + + if (hasAcknowledgeLabel) { + await github.graphql( + `mutation { + minimizeComment(input:{subjectId:"${newCommentId}", classifier:RESOLVED}){ + clientMutationId + } + }` + ) + } - name: Evaluate Result if: ${{ !contains(github.event.pull_request.labels.*.name, 'acknowledge-artifact-size-increase') }}