Repository: cli/cli
File: .github/workflows/scripts/check-help-wanted.sh (Shell)

Code before:
    echo "Checking issue #$issue_num for help-wanted label..."

    # Get issue labels
    LABELS=$(gh issue view "$issue_num" --json labels --jq '.labels[].name')

    # Check if help-wanted label exists
    if ! echo "$LABELS" | grep -q "help-wanted"; then
        ISSUES_WITHOUT_HELP_WANTED+=("$issue_num")
        echo "Issue #$issue_num does not have help-wanted label"
    else
        echo "Issue #$issue_num has help-wanted label"
    fi
done

# If we found issues without help-wanted label, post a comment
if [ ${#ISSUES_WITHOUT_HELP_WANTED[@]} -gt 0 ]; then
    echo "Found ${#ISSUES_WITHOUT_HELP_WANTED[@]} issues without help-wanted label"

    # Build issue list for comment
    ISSUE_LIST=""
    for issue_num in "${ISSUES_WITHOUT_HELP_WANTED[@]}"; do
        ISSUE_LIST="$ISSUE_LIST- #$issue_num"$'\n'
    done

    # Create comment message
    COMMENT_MESSAGE="Thank you for your pull request! 🎉

This PR appears to fix the following issues that are not labeled with \`help-wanted\`:

$ISSUE_LIST
As outlined in our [Contributing Guidelines](https://github.com/cli/cli/blob/trunk/.github/CONTRIBUTING.md), we expect that PRs are only created for issues that have been labeled \`help-wanted\`.

While we appreciate your initiative, please note that:

- **PRs for non-\`help-wanted\` issues may not be reviewed immediately** as they might not align with our current priorities
- **The issue might already be assigned** to a team member or planned for a specific release
- **We may need to close this PR** if it conflicts with ongoing work or architectural decisions

**What happens next:**
- Our team will review this PR and the associated issues
- We may add the \`help-wanted\` label to the issues if appropriate
- We may provide feedback on the approach or request changes
- In some cases, we may need to close the PR if it doesn't fit our current roadmap

Thank you for your understanding and contribution to the project! 🙏

*This comment was automatically generated by cliAutomation.*"

    # Post the comment
    gh pr comment "$PR_URL" --body "$COMMENT_MESSAGE"
    echo "Posted comment on PR #$PRNUM"

Review comment (suggestion):
**thought:** this could be enhanced using heredoc syntax that allows tab spacing if anyone has issues reading or managing it.

For more info, https://www.oreilly.com/library/view/bash-cookbook/0596526784/ch03s04.html

Code after:
    echo "Checking issue #$issue_num for 'help wanted' label..."

    # Get issue labels
    LABELS=$(gh issue view "$issue_num" --json labels --jq '.labels[].name')

    # Skip if the issue has the gh-attestion or gh-codespace label
    # This is because the codeowners for these commands may not be public
    # cli org members, and so unless we authenticate with a PAT, we can't
    # know who is an external contributor or not.
    # So we skip these issues to avoid falsely writing a comment
    # on each PR opened by these codeowners.
    if echo "$LABELS" | grep -q -e "gh-attestation" -e "gh-codespace"; then
        echo "Issue #$issue_num is skipped due to labels"
        continue
    fi

    # Check if 'help wanted' label exists
    if ! echo "$LABELS" | grep -q "help wanted"; then
        ISSUES_WITHOUT_HELP_WANTED+=("$issue_num")
        echo "Issue #$issue_num does not have 'help wanted' label"
    else
        echo "Issue #$issue_num has 'help wanted' label"
    fi
done

# If we found issues without 'help wanted' label, post a comment
if [ ${#ISSUES_WITHOUT_HELP_WANTED[@]} -gt 0 ]; then
    echo "Found ${#ISSUES_WITHOUT_HELP_WANTED[@]} issues without 'help wanted' label"

    # Build issue list for comment
    ISSUE_LIST=""
    for issue_num in "${ISSUES_WITHOUT_HELP_WANTED[@]}"; do
        ISSUE_LIST="$ISSUE_LIST- #$issue_num"$'\n'
    done

    # Create comment message
    gh pr comment "$PR_URL" --body-file - <<EOF
Thank you for your pull request! 🎉

This PR appears to fix the following issues that are not labeled with \`help wanted\`:

$ISSUE_LIST
As outlined in our [Contributing Guidelines](https://github.com/cli/cli/blob/trunk/.github/CONTRIBUTING.md), we expect that PRs are only created for issues that have been labeled \`help wanted\`.

While we appreciate your initiative, please note that:

- **PRs for non-\`help wanted\` issues may not be reviewed immediately** as they might not align with our current priorities
- **The issue might already be assigned** to a team member or planned for a specific release
- **We may need to close this PR**. For example, if it conflicts with ongoing work or architectural decisions

**What happens next:**