From c6c47656975e405bb1755019cd46f59d77ebdac4 Mon Sep 17 00:00:00 2001 From: Joe Clark <31087804+jc-clark@users.noreply.github.com> Date: Fri, 21 Mar 2025 14:47:51 -0700 Subject: [PATCH] Update the DIY docs script in ready-for-doc-review to use the GitHub CLI (#54951) --- .github/workflows/ready-for-doc-review.yml | 32 ++++++++-------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ready-for-doc-review.yml b/.github/workflows/ready-for-doc-review.yml index 6b71cc857e44..25c46eb4cf23 100644 --- a/.github/workflows/ready-for-doc-review.yml +++ b/.github/workflows/ready-for-doc-review.yml @@ -51,31 +51,21 @@ jobs: run: | echo "Extracting issue numbers from PR description..." - # Clean up PR description to avoid syntax errors in grep command - PR_BODY="${{ github.event.pull_request.body }}" - echo "PR description to use in the script: $PR_BODY" - - ISSUE_NUMS=$(echo "$PR_BODY" | grep -oE '(https://github.com/github/docs-content/issues/[0-9]+|github/docs-content#[0-9]+|#[0-9]+)' | grep -oE '[0-9]+$') - echo "Extracted issue numbers: $ISSUE_NUMS" + # Get issue numbers directly using gh pr view + ISSUE_NUMS=$(gh pr view ${{ github.event.pull_request.number }} --json body -q .body | \ + grep -oE '(https://github.com/github/docs-content/issues/[0-9]+|github/docs-content#[0-9]+|#[0-9]+)' | \ + grep -oE '[0-9]+$' || echo "") + echo "Extracted docs-content issue numbers: $ISSUE_NUMS" if [ -n "$ISSUE_NUMS" ]; then for ISSUE_NUM in $ISSUE_NUMS; do - # Check if the issue exists in the docs-content repository - echo "Checking issue $ISSUE_NUM in the docs-content repository..." - if gh issue view $ISSUE_NUM --repo github/docs-content --json labels > /dev/null 2>&1; then - echo "Issue $ISSUE_NUM exists in docs-content. Fetching labels..." - # Fetch labels for the issue - LABELS=$(gh issue view $ISSUE_NUM --repo github/docs-content --json labels --jq '.labels[].name' || echo "") - echo "Labels for issue $ISSUE_NUM: $LABELS" - if echo "$LABELS" | grep -q 'DIY docs'; then - echo "DIY docs label found for issue $ISSUE_NUM." - echo "DIY_DOCS_LABEL=true" >> $GITHUB_ENV - break - else - echo "DIY docs label not found for issue $ISSUE_NUM." - fi + echo "Checking issue #$ISSUE_NUM in the docs-content repository..." + if gh issue view $ISSUE_NUM --repo github/docs-content --json labels -q '.labels[].name' | grep -q 'DIY docs'; then + echo "DIY docs label found for issue #$ISSUE_NUM." + echo "DIY_DOCS_LABEL=true" >> $GITHUB_ENV + break else - echo "Issue $ISSUE_NUM does not exist in the docs-content repository." + echo "Issue #$ISSUE_NUM exists but does not have the DIY docs label." fi done else