Skip to content

Commit 882b603

Browse files
authored
Combine review comments to avoid duplicates (#54495)
1 parent 133dae1 commit 882b603

File tree

3 files changed

+94
-226
lines changed

3 files changed

+94
-226
lines changed

.github/workflows/comment-code-changes.yml

Lines changed: 0 additions & 77 deletions
This file was deleted.

.github/workflows/comment-content-changes-table.yml

Lines changed: 0 additions & 149 deletions
This file was deleted.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Review comment
2+
3+
# **What it does**: When a PR is opened in docs-internal or docs containing code, it comments with instructions on how to deploy and review the changes. it adds the staging review and live article links in a Content Directory Changes table in a comment.
4+
# **Why we have it**: To help Docs contributors understand how to review their changes.
5+
# **Who does it impact**: docs-internal and docs maintainers and contributors
6+
7+
on:
8+
# Required in lieu of `pull_request` so that the comment can be posted to PRs opened from a fork.
9+
pull_request_target:
10+
types:
11+
- opened
12+
- synchronize
13+
14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
18+
# This allows a subsequently queued workflow run to interrupt previous runs
19+
concurrency:
20+
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
21+
cancel-in-progress: true
22+
23+
jobs:
24+
review-comment:
25+
if: ${{ github.event.pull_request.user.login != 'docs-bot' && (github.repository == 'github/docs-internal' || github.repository == 'github/docs') }}
26+
runs-on: ubuntu-latest
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
PR_NUMBER: ${{ github.event.pull_request.number }}
30+
steps:
31+
- name: check out repo content
32+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
33+
- uses: ./.github/actions/node-npm-setup
34+
# We're setting the URLs manually until we merge in-progress work. We can utilize review server and its helper functions in a later iteration.
35+
- name: Set APP_URL
36+
run: |
37+
if [[ "${{ github.repository }}" == "github/docs-internal" ]]; then
38+
echo "APP_URL=https://docs-review.github.com" >> $GITHUB_ENV
39+
elif [[ "${{ github.repository }}" == "github/docs" ]]; then
40+
echo "APP_URL=https://os-docs-review.github.com" >> $GITHUB_ENV
41+
fi
42+
- name: Find code changes comment
43+
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e
44+
id: findComment
45+
with:
46+
issue-number: ${{ github.event.pull_request.number }}
47+
comment-author: 'github-actions[bot]'
48+
body-includes: '<!-- REVIEW_COMMENT -->'
49+
- name: Get changes table
50+
id: changes
51+
timeout-minutes: 30
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
REVIEW_SERVER_ACCESS_TOKEN: ${{ secrets.REVIEW_SERVER_ACCESS_TOKEN }}
55+
APP_URL: ${{ env.APP_URL }}
56+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
57+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
58+
# HEAD_BRANCH isn't necessary for the table comment, but lets us list the branch in the review server menu bar
59+
HEAD_BRANCH: ${{ github.event.pull_request.head.ref }}
60+
run: npm run content-changes-table-comment
61+
- name: Update comment
62+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
63+
with:
64+
comment-id: ${{ steps.findComment.outputs.comment-id }}
65+
issue-number: ${{ github.event.pull_request.number || inputs.PR_NUMBER }}
66+
edit-mode: replace
67+
body: |
68+
<!-- REVIEW_COMMENT -->
69+
### How to review these changes 👓
70+
71+
Thank you for your contribution. To review these changes, choose one of the following options:
72+
73+
* [Spin up a codespace][codespace]
74+
* [Set up a local development environment][local]
75+
${{ github.repository == "github/docs" && '' || '* Message `#docs-engineering` on Slack for a staging server.' }}
76+
77+
[codespace]: ${{ github.repository == "github/docs" && 'https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/working-on-github-docs-in-a-codespace' || 'https://github.com/github/docs-team/blob/main/contributing-to-docs/use-a-codespace-to-review.md' }}
78+
[local]: https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment#setting-up-your-local-environment
79+
80+
${{ github.repository == "github/docs" && 'A Hubber will need to deploy your changes internally to review.' || '' }}
81+
82+
<details><summary>Table of review links</summary>
83+
84+
⚠️ **Warning**: Our review server is experiencing latency issues.
85+
86+
${{ steps.changes.outputs.changesTable && 'The table shows the files in the `content` directory that were changed in this pull request. This helps you review your changes on the review server. Changes to the `data` directory are not included in this table.' || '' }}
87+
88+
${{ steps.changes.outputs.changesTable || '_This pull request contains code changes, so we will not generate a table of review links._' }}
89+
90+
${{ steps.changes.outputs.changesTable && 'Key: **fpt**: Free, Pro, Team; **ghec**: GitHub Enterprise Cloud; **ghes**: GitHub Enterprise Server' || '' }}
91+
92+
</details>
93+
94+
🤖 This comment is [automatically generated](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/.github/workflows/review-comment.yml).

0 commit comments

Comments
 (0)