|
43 | 43 | echo "AUTHOR_LOGIN=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV |
44 | 44 | fi |
45 | 45 |
|
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 | | - if: github.repository == 'github/docs-internal' |
49 | | - id: check-diy-docs |
50 | | - env: |
51 | | - GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }} |
52 | | - run: | |
53 | | - echo "Extracting issue numbers from PR description..." |
54 | | -
|
55 | | - # Get issue numbers directly using gh pr view |
56 | | - ISSUE_NUMS=$(gh pr view ${{ github.event.pull_request.number }} --json body -q .body | \ |
57 | | - grep -oE '(https://github.com/github/docs-content/issues/[0-9]+|github/docs-content#[0-9]+|#[0-9]+)' | \ |
58 | | - grep -oE '[0-9]+$' || echo "") |
59 | | - echo "Extracted docs-content issue numbers: $ISSUE_NUMS" |
60 | | -
|
61 | | - if [ -n "$ISSUE_NUMS" ]; then |
62 | | - for ISSUE_NUM in $ISSUE_NUMS; do |
63 | | - echo "Checking issue #$ISSUE_NUM in the docs-content repository..." |
64 | | - if gh issue view $ISSUE_NUM --repo github/docs-content --json labels -q '.labels[].name' | grep -q 'DIY docs'; then |
65 | | - echo "DIY docs label found for issue #$ISSUE_NUM." |
66 | | - echo "DIY_DOCS_LABEL=true" >> $GITHUB_ENV |
67 | | - break |
68 | | - else |
69 | | - echo "Issue #$ISSUE_NUM exists but does not have the DIY docs label." |
70 | | - fi |
71 | | - done |
72 | | - else |
73 | | - echo "No DIY docs issues found in the PR description." |
74 | | - fi |
75 | | -
|
76 | | - # Debug step to confirm environment variables are set correctly |
77 | | - - name: Debug environment variables |
78 | | - run: | |
79 | | - echo "Current environment variables:" |
80 | | - echo "DIY_DOCS_LABEL: $DIY_DOCS_LABEL" |
81 | | - echo "Repository: ${{ github.repository }}" |
82 | | -
|
83 | | - # If the PR description contains a link to a DIY docs issue, add the DIY docs label to the PR. |
84 | | - - name: Add the DIY docs label if connected to a DIY docs issue |
85 | | - if: ${{ env.DIY_DOCS_LABEL == 'true' }} && github.repository == 'github/docs-internal' |
86 | | - env: |
87 | | - GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }} |
88 | | - PR_URL: ${{ github.event.pull_request.html_url }} |
89 | | - run: | |
90 | | - # Debugging output |
91 | | - echo "Condition check:" |
92 | | - echo "DIY_DOCS_LABEL is: $DIY_DOCS_LABEL" |
93 | | - echo "github.repository is: ${{ github.repository }}" |
94 | | - echo "Adding the DIY docs label..." |
95 | | - gh pr edit $PR_URL --add-label 'DIY docs' |
96 | | -
|
97 | 46 | - name: Run script |
98 | 47 | run: | |
99 | 48 | npm run ready-for-docs-review |
|
0 commit comments