Skip to content

Commit 96e39dd

Browse files
jc-clarkJoe Clark
andauthored
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>
1 parent 4ef3867 commit 96e39dd

2 files changed

Lines changed: 36 additions & 24 deletions

File tree

.github/workflows/first-responder-v2-prs-collect.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,6 @@ jobs:
6565
run: |
6666
gh pr edit $PR_URL --add-label docs-content-fr
6767
68-
# 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.
69-
- name: Check if PR is connected to DIY docs issue
70-
id: check-diy-docs
71-
env:
72-
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }}
73-
run: |
74-
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]+')
75-
for ISSUE_NUM in $ISSUE_NUMS; do
76-
LABELS=$(gh issue view $ISSUE_NUM --repo github/docs-content --json labels --jq '.labels[].name')
77-
if echo "$LABELS" | grep -q 'DIY docs'; then
78-
echo "DIY_DOCS_LABEL=true" >> $GITHUB_ENV
79-
break
80-
fi
81-
done
82-
83-
- name: Add the DIY docs label if connected to a DIY docs issue
84-
if: ${{ env.DIY_DOCS_LABEL == 'true' }}
85-
env:
86-
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }}
87-
PR_URL: ${{ github.event.pull_request.html_url }}
88-
run: |
89-
gh pr edit $PR_URL --add-label 'DIY docs'
90-
9168
# Add to the FR project
9269
# and set type to "Maintenance" or "External contributor PR"
9370
# and set date to now

.github/workflows/ready-for-doc-review.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Ready for docs-content review
22

3-
# **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.
3+
# **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.
44
# **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
55
# **Who does it impact**: Writers who need to review docs-related PRs
66

@@ -43,6 +43,41 @@ jobs:
4343
echo "AUTHOR_LOGIN=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV
4444
fi
4545
46+
# 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.
47+
- name: Check if PR is connected to DIY docs issue
48+
id: check-diy-docs
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }}
51+
run: |
52+
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]+$')
53+
54+
if [ -n "$ISSUE_NUMS" ]; then
55+
for ISSUE_NUM in $ISSUE_NUMS; do
56+
# Check if the issue exists in the docs-content repository
57+
ISSUE_REPO=$(gh issue view $ISSUE_NUM --repo github/docs-content --json repository --jq '.repository.name' 2>/dev/null || echo "")
58+
59+
# Fetch labels only if the issue exists in the docs-content repository
60+
if [ "$ISSUE_REPO" == "docs-content" ]; then
61+
LABELS=$(gh issue view $ISSUE_NUM --repo github/docs-content --json labels --jq '.labels[].name' 2>/dev/null || echo "")
62+
if echo "$LABELS" | grep -q 'DIY docs'; then
63+
echo "DIY_DOCS_LABEL=true" >> $GITHUB_ENV
64+
break
65+
fi
66+
fi
67+
done
68+
else
69+
echo "No DIY docs issues found in the PR description."
70+
fi
71+
72+
# If the PR description contains a link to a DIY docs issue, add the DIY docs label to the PR.
73+
- name: Add the DIY docs label if connected to a DIY docs issue
74+
if: ${{ env.DIY_DOCS_LABEL == 'true' }}
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }}
77+
PR_URL: ${{ github.event.pull_request.html_url }}
78+
run: |
79+
gh pr edit $PR_URL --add-label 'DIY docs'
80+
4681
- name: Run script
4782
run: |
4883
npm run ready-for-docs-review

0 commit comments

Comments
 (0)