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