diff --git a/.github/workflows/ready-for-doc-review.yml b/.github/workflows/ready-for-doc-review.yml index 25c46eb4cf23..6b71cc857e44 100644 --- a/.github/workflows/ready-for-doc-review.yml +++ b/.github/workflows/ready-for-doc-review.yml @@ -51,21 +51,31 @@ jobs: run: | echo "Extracting issue numbers from PR description..." - # 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" + # 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" if [ -n "$ISSUE_NUMS" ]; then for ISSUE_NUM in $ISSUE_NUMS; do - 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 + # 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 else - echo "Issue #$ISSUE_NUM exists but does not have the DIY docs label." + echo "Issue $ISSUE_NUM does not exist in the docs-content repository." fi done else