Fix the DIY docs label workflow commands and add them to the ready-for-doc-review workflow (#54891)
Co-authored-by: Joe Clark <joeclark@cfvjt2x3qw.localdomain>
This commit is contained in:
@@ -65,29 +65,6 @@ jobs:
|
||||
run: |
|
||||
gh pr edit $PR_URL --add-label docs-content-fr
|
||||
|
||||
# Check if the PR is connected to an issue that has the DIY docs label. If yes, then add the DIY docs label to the PR.
|
||||
- name: Check if PR is connected to DIY docs issue
|
||||
id: check-diy-docs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }}
|
||||
run: |
|
||||
ISSUE_NUMS=$(echo "${{ github.event.pull_request.body }}" | grep -oE '(https://github.com/github/docs-content/issues/[0-9]+|#[0-9]+)' | grep -oE '[0-9]+')
|
||||
for ISSUE_NUM in $ISSUE_NUMS; do
|
||||
LABELS=$(gh issue view $ISSUE_NUM --repo github/docs-content --json labels --jq '.labels[].name')
|
||||
if echo "$LABELS" | grep -q 'DIY docs'; then
|
||||
echo "DIY_DOCS_LABEL=true" >> $GITHUB_ENV
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Add the DIY docs label if connected to a DIY docs issue
|
||||
if: ${{ env.DIY_DOCS_LABEL == 'true' }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }}
|
||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||
run: |
|
||||
gh pr edit $PR_URL --add-label 'DIY docs'
|
||||
|
||||
# Add to the FR project
|
||||
# and set type to "Maintenance" or "External contributor PR"
|
||||
# and set date to now
|
||||
|
||||
37
.github/workflows/ready-for-doc-review.yml
vendored
37
.github/workflows/ready-for-doc-review.yml
vendored
@@ -1,6 +1,6 @@
|
||||
name: Ready for docs-content review
|
||||
|
||||
# **What it does**: Adds pull requests in the docs-internal repository to the docs-content review board when the "ready-for-doc-review" label is added or when a review by docs-content or docs-reviewers is requested. This workflow is also called as a reusable workflow from other repos including docs-content, docs-strategy, docs-early-access, and github.
|
||||
# **What it does**: Adds pull requests in the docs-internal repository to the docs-content review board when the "ready-for-doc-review" label is added or when a review by docs-content or docs-reviewers is requested. Adds the "DIY docs" label to the PR if it is connected to a DIY docs issue in the docs-content repo. This workflow is also called as a reusable workflow from other repos including docs-content, docs-strategy, docs-early-access, and github.
|
||||
# **Why we have it**: So that other GitHub teams can easily request reviews from the docs-content team, and so that writers can see when a PR is ready for review
|
||||
# **Who does it impact**: Writers who need to review docs-related PRs
|
||||
|
||||
@@ -43,6 +43,41 @@ jobs:
|
||||
echo "AUTHOR_LOGIN=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
# Check if the PR is connected to an issue that has the DIY docs label. The grep command parses through the PR description to find issue numbers that are linked in the PR description. The GitHub CLI command then checks if the issue exists in the docs-content repo, then checks if the linked docs-content issues have the DIY docs label. If the linked issues have the DIY docs label, the DIY_DOCS_LABEL environment variable is set to true.
|
||||
- name: Check if PR is connected to DIY docs issue
|
||||
id: check-diy-docs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }}
|
||||
run: |
|
||||
ISSUE_NUMS=$(echo "${{ github.event.pull_request.body }}" | grep -oE '(https://github.com/github/docs-content/issues/[0-9]+|github/docs-content#[0-9]+|#[0-9]+)' | grep -oE '^[0-9]+$')
|
||||
|
||||
if [ -n "$ISSUE_NUMS" ]; then
|
||||
for ISSUE_NUM in $ISSUE_NUMS; do
|
||||
# Check if the issue exists in the docs-content repository
|
||||
ISSUE_REPO=$(gh issue view $ISSUE_NUM --repo github/docs-content --json repository --jq '.repository.name' 2>/dev/null || echo "")
|
||||
|
||||
# Fetch labels only if the issue exists in the docs-content repository
|
||||
if [ "$ISSUE_REPO" == "docs-content" ]; then
|
||||
LABELS=$(gh issue view $ISSUE_NUM --repo github/docs-content --json labels --jq '.labels[].name' 2>/dev/null || echo "")
|
||||
if echo "$LABELS" | grep -q 'DIY docs'; then
|
||||
echo "DIY_DOCS_LABEL=true" >> $GITHUB_ENV
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "No DIY docs issues found in the PR description."
|
||||
fi
|
||||
|
||||
# If the PR description contains a link to a DIY docs issue, add the DIY docs label to the PR.
|
||||
- name: Add the DIY docs label if connected to a DIY docs issue
|
||||
if: ${{ env.DIY_DOCS_LABEL == 'true' }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }}
|
||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||
run: |
|
||||
gh pr edit $PR_URL --add-label 'DIY docs'
|
||||
|
||||
- name: Run script
|
||||
run: |
|
||||
npm run ready-for-docs-review
|
||||
|
||||
Reference in New Issue
Block a user