-
Notifications
You must be signed in to change notification settings - Fork 60.9k
134 lines (113 loc) · 7.51 KB
/
comment-content-changes-table.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Content Changes Table Comment
# **What it does**: When a PR is opened in docs-internal or docs, it adds the staging preview 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 -->
## 👓 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 review server. Please note that changes to the `data` directory will not show up in this table.
:bangbang: You can also preview changes [using Codespaces](https://github.com/github/docs-engineering/blob/main/docs/team-practices/use-a-codespace-to-review.md) or by [spinning up a local environment](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment). Please continue to [let us know](https://github.com/github/docs-team/discussions/4889) if you have trouble with the review server and use one of those options to preview your changes.
---
### Content directory changes
_You may find it useful to copy this table into the pull request summary. There you can edit it to share links to important articles or changes and to give a high-level overview of how the changes in your pull request support the overall goals of the pull request._
${{ 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._
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 -->
## 👓 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 review server. Please note that changes to the `data` directory will not show up in this table.
:bangbang: You can also preview changes [using Codespaces](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/working-on-github-docs-in-a-codespace) or by [spinning up a local environment](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment). If you have trouble with the review server, use one of those options to preview your changes.
---
### Content directory changes
_You may find it useful to copy this table into the pull request summary. There you can edit it to share links to important articles or changes and to give a high-level overview of how the changes in your pull request support the overall goals of the pull request._
${{ 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._
edit-mode: replace