Use review server URL for content changes table (#53812)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com> Co-authored-by: Evan Bonsignori <ebonsignori@github.com>
This commit is contained in:
66
.github/workflows/code-changes-comment.yml
vendored
Normal file
66
.github/workflows/code-changes-comment.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
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 preview the changes.
|
||||
# **Why we have it**: To help Docs contributors understand how to preview 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/reusables/**'
|
||||
- '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 -->
|
||||
## 🚀 Manual Deployment Required
|
||||
|
||||
It looks like this pull request contains code changes. To preview these changes, an internal Hubber will need to manually deploy the changes to one of our staging servers.
|
||||
|
||||
Thank you for your contribution!"
|
||||
else
|
||||
COMMENT_BODY="<!-- CODE_CHANGES_COMMENT -->
|
||||
## 🚀 Manual Deployment Required
|
||||
|
||||
It looks like this pull request contains code changes. To preview these changes, you will need to deploy them manually.
|
||||
|
||||
Thank you for your contribution!"
|
||||
fi
|
||||
|
||||
gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT_BODY"
|
||||
@@ -28,6 +28,7 @@ on:
|
||||
paths:
|
||||
- 'content/**'
|
||||
- 'data/reusables/**'
|
||||
- 'assets/images/**'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -48,21 +49,28 @@ jobs:
|
||||
- name: check out repo content
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: Get preview app info
|
||||
env:
|
||||
APP_NAME_SEED: ${{ secrets.PREVIEW_ENV_NAME_SEED }}
|
||||
run: src/workflows/get-preview-app-info.sh
|
||||
|
||||
- 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
|
||||
@@ -81,10 +89,10 @@ jobs:
|
||||
issue-number: ${{ github.event.pull_request.number || inputs.PR_NUMBER }}
|
||||
body: |
|
||||
<!-- MODIFIED_CONTENT_LINKING_COMMENT -->
|
||||
## Automatically generated comment ℹ️
|
||||
**This comment is automatically generated and will be overwritten every time changes are committed to this branch.**
|
||||
## 👓 Previews for changed content
|
||||
**This comment is 🤖 automatically generated and will be overwritten every time changes are committed to this branch.**
|
||||
|
||||
The table contains an overview of files in the `content` directory that have been changed in this pull request. It's provided to make it easy to review your changes on the staging site. Please note that changes to the `data` directory will not show up in this table.
|
||||
The table contains an overview of files in the `content` directory that have been changed in this pull request. It's provided to make it easy to review your changes on the review server. Please note that changes to the `data` directory will not show up in this table.
|
||||
|
||||
---
|
||||
|
||||
@@ -93,7 +101,6 @@ jobs:
|
||||
${{ steps.changes.outputs.changesTable }}
|
||||
|
||||
---
|
||||
fpt: Free, Pro, Team
|
||||
ghec: GitHub Enterprise Cloud
|
||||
ghes: GitHub Enterprise Server
|
||||
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/content-changes-table-comment.yml) workflow._
|
||||
edit-mode: replace
|
||||
|
||||
Reference in New Issue
Block a user