-
Notifications
You must be signed in to change notification settings - Fork 61k
103 lines (87 loc) · 5.25 KB
/
review-comment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Review comment
# **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.
# **Why we have it**: To help Docs contributors understand how to review their changes.
# **Who does it impact**: docs-internal and docs maintainers and contributors
on:
# Required in lieu of `pull_request` so that the comment can be posted to PRs opened from a fork.
pull_request_target:
types:
- opened
- synchronize
paths-ignore:
- '.github/workflows/review-comment.yml'
# For reviewing changes to this workflow
pull_request:
types:
- opened
- synchronize
paths:
- '.github/workflows/review-comment.yml'
permissions:
contents: read
pull-requests: write
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
review-comment:
if: ${{ github.event.pull_request.user.login != 'docs-bot' && (github.repository == 'github/docs-internal' || github.repository == 'github/docs') }}
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
- name: check out repo content
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: ./.github/actions/node-npm-setup
# 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.
- name: Set APP_URL
run: |
if [[ "${{ github.repository }}" == "github/docs-internal" ]]; then
echo "APP_URL=https://docs-review.github.com" >> $GITHUB_ENV
elif [[ "${{ github.repository }}" == 'github/docs' ]]; then
echo "APP_URL=https://os-docs-review.github.com" >> $GITHUB_ENV
fi
- name: Find code changes comment
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e
id: findComment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- REVIEW_COMMENT -->'
- name: Get changes table
id: changes
timeout-minutes: 30
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REVIEW_SERVER_ACCESS_TOKEN: ${{ secrets.REVIEW_SERVER_ACCESS_TOKEN }}
APP_URL: ${{ env.APP_URL }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
# HEAD_BRANCH isn't necessary for the table comment, but lets us list the branch in the review server menu bar
HEAD_BRANCH: ${{ github.event.pull_request.head.ref }}
run: npm run content-changes-table-comment
- name: Update comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
comment-id: ${{ steps.findComment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number || inputs.PR_NUMBER }}
edit-mode: replace
body: |
<!-- REVIEW_COMMENT -->
### How to review these changes 👓
Thank you for your contribution. To review these changes, choose one of the following options:
* [Spin up a codespace][codespace]
* [Set up a local development environment][local]
${{ github.repository == 'github/docs' && '' || '* Message `#docs-engineering` on Slack for a staging server.' }}
[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' }}
[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
${{ github.repository == 'github/docs' && 'A Hubber will need to deploy your changes internally to review.' || '' }}
<details><summary>Table of review links</summary>
⚠️ **Warning**: Our review server is experiencing latency issues.
${{ 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.' || '' }}
${{ steps.changes.outputs.changesTable || '_This pull request contains code changes, so we will not generate a table of review links._' }}
${{ steps.changes.outputs.changesTable && 'Key: **fpt**: Free, Pro, Team; **ghec**: GitHub Enterprise Cloud; **ghes**: GitHub Enterprise Server' || '' }}
</details>
🤖 This comment is [automatically generated](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/.github/workflows/review-comment.yml).