From 5b84b51488e2bc69356d694c548889b68ab61cf9 Mon Sep 17 00:00:00 2001 From: Ronnie Miller Date: Tue, 12 Aug 2025 10:18:09 -0700 Subject: [PATCH] docs: Hide previous docs draft build comments on new build (#9334) --- .github/workflows/deploy-docs-draft.yml | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/deploy-docs-draft.yml b/.github/workflows/deploy-docs-draft.yml index c79ace21d..b5a866d87 100644 --- a/.github/workflows/deploy-docs-draft.yml +++ b/.github/workflows/deploy-docs-draft.yml @@ -96,6 +96,41 @@ jobs: echo $MULTILINE_LOG >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV + - name: Hide Previous Build Comments + if: ${{ github.event.pull_request.number && (success() || failure()) }} + run: | + set -e + + # Get all comments on the PR that match our build comments + comments=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ + --jq '.[] | select(.body | test("Build failure! :x:|Build successful! :white_check_mark:")) | .node_id') + + # Minimize each matching comment using GraphQL API + if [[ -n "$comments" ]]; then + echo "Found previous build comments to hide" + while IFS= read -r comment_id; do + if [[ -n "$comment_id" ]]; then + echo "Minimizing comment: $comment_id" + gh api graphql \ + --field id="$comment_id" \ + --field classifier="OUTDATED" \ + --raw-field query=' + mutation($id: ID!, $classifier: ReportedContentClassifiers!) { + minimizeComment(input: { subjectId: $id, classifier: $classifier }) { + minimizedComment { + isMinimized + } + } + }' || echo "Failed to minimize comment $comment_id, continuing..." + echo + fi + done <<< "$comments" + else + echo "No previous build comments found to hide" + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Assemble Build Success Comment if: success() run: |