1
0
mirror of synced 2026-01-07 00:01:39 -05:00

Combine review comments to avoid duplicates (#54495)

This commit is contained in:
Kevin Heis
2025-02-20 13:27:05 -08:00
committed by GitHub
parent 133dae1ea8
commit 882b60348e
3 changed files with 94 additions and 226 deletions

View File

@@ -1,77 +0,0 @@
name: Code changes 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.
# **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
# this applies to any non-content files, this workflow will run for all changed files unless it's ONLY these content-related changes
paths-ignore:
- 'content/**'
- 'data/**'
- 'assets/images/**'
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:
postOnCodeChanges:
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 }}
steps:
- name: check out repo content
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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: '<!-- CODE_CHANGES_COMMENT -->'
# TODO: We'll update this comment at a later time with permament-ish links to deployment instructions.
- name: Comment on code changes
if: ${{ !steps.findComment.outputs.comment-id }}
run: |
if [[ "${{ github.repository }}" == "github/docs" ]]; then
COMMENT_BODY="<!-- CODE_CHANGES_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](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/working-on-github-docs-in-a-codespace)
* [Set up a local development environment](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment#setting-up-your-local-environment)
This pull request contains code changes, so we will not generate a table of review links. A Hubber will need to deploy your changes internally to review.
🤖 This comment is automatically generated."
else
COMMENT_BODY="<!-- CODE_CHANGES_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](https://github.com/github/docs-team/blob/main/contributing-to-docs/use-a-codespace-to-review.md).
* [Set up a local development environment](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment#setting-up-your-local-environment).
* Message \`#docs-engineering\` on Slack for a staging server.
This pull request contains code changes, so we will not generate a table of review links.
🤖 This comment is automatically generated."
fi
gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT_BODY"

View File

@@ -1,149 +0,0 @@
name: Content Changes Table Comment
# **What it does**: When a PR is opened in docs-internal or docs, 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 Content team members and contributors automatically have their staging/live article links added to the table
# **Who does it impact**: docs-internal/docs maintainers and contributors
on:
workflow_dispatch:
inputs:
PR_NUMBER:
description: 'PR Number'
type: string
required: true
BASE_SHA:
description: 'Base SHA'
type: string
required: true
default: 'main'
HEAD_SHA:
description: 'Head SHA (latest sha of the PR)'
type: string
required: true
# Required in lieu of `pull_request` so that the content changes tables can be posts to PRs opened from a fork.
pull_request_target:
types:
- opened
- synchronize
paths:
- 'content/**'
- 'data/**'
- 'assets/images/**'
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:
filterContentDir:
if: ${{ github.event.pull_request.user.login != 'docs-bot' && (github.repository == 'github/docs-internal' || github.repository == 'github/docs') }}
runs-on: ubuntu-latest
env:
PR_NUMBER: ${{ github.event.pull_request.number || inputs.PR_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: 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 || inputs.BASE_SHA }}
HEAD_SHA: ${{ github.event.pull_request.head.sha || inputs.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: Find content directory changes comment
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e
id: findComment
with:
issue-number: ${{ github.event.pull_request.number || inputs.PR_NUMBER }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- MODIFIED_CONTENT_LINKING_COMMENT -->'
- name: Update comment on docs-internal
if: ${{github.repository == 'github/docs-internal' && steps.changes.outputs.changesTable != '' }}
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 }}
body: |
<!-- MODIFIED_CONTENT_LINKING_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](https://github.com/github/docs-team/blob/main/contributing-to-docs/use-a-codespace-to-review.md).
* [Set up a local development environment](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment#setting-up-your-local-environment).
* Message \`#docs-engineering\` on Slack for a staging server.
<details><summary>Table of review links</summary>
⚠️ **Warning**: Our review server is experiencing latency issues.
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. If you have issues with the review server, please [let us know](https://github.com/github/docs-team/discussions/4889) and use one of the other options to review your changes.
${{ steps.changes.outputs.changesTable }}
---
Key: **fpt**: Free, Pro, Team; **ghec**: GitHub Enterprise Cloud; **ghes**: GitHub Enterprise Server
_This table is posted from the [${{ github.workflow }}](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/.github/workflows/comment-content-changes-table.yml) workflow._
</details>
🤖 This comment is automatically generated.
edit-mode: replace
- name: Update comment on docs public
if: ${{github.repository == 'github/docs' && steps.changes.outputs.changesTable != '' }}
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 }}
body: |
<!-- MODIFIED_CONTENT_LINKING_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](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/working-on-github-docs-in-a-codespace)
* [Set up a local development environment](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment#setting-up-your-local-environment)
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.
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 }}
---
Key: **fpt**: Free, Pro, Team; **ghec**: GitHub Enterprise Cloud; **ghes**: GitHub Enterprise Server
_This table is posted from the [${{ github.workflow }}](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/.github/workflows/comment-content-changes-table.yml) workflow._
</details>
🤖 This comment is automatically generated.
edit-mode: replace

94
.github/workflows/review-comment.yml vendored Normal file
View File

@@ -0,0 +1,94 @@
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
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).