Skip to content

Commit 54459f5

Browse files
hubwriterCopilot
andauthored
Add an Actions workflow to prompt folks to update the docs changelog (#57067)
Co-authored-by: Copilot <[email protected]>
1 parent 3afe669 commit 54459f5

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Changelog prompt when a PR is closed
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
comment-on-pr:
13+
# This workflow should only run on the 'github/docs-internal' repository because it posts changelog instructions
14+
# and links that are specific to the internal documentation process and resources.
15+
# It also only runs if PR is merged into the main branch.
16+
if: github.repository == 'github/docs-internal' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Check if PR author is in docs-content team
22+
id: check_team
23+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
24+
with:
25+
github-token: ${{ secrets.DOCS_BOT_PAT_BASE }}
26+
script: |
27+
try {
28+
const pr = context.payload.pull_request;
29+
await github.rest.teams.getMembershipForUserInOrg({
30+
org: 'github',
31+
team_slug: 'docs-content',
32+
username: pr.user.login,
33+
});
34+
core.exportVariable('CONTINUE_WORKFLOW', 'true');
35+
} catch(err) {
36+
core.info("Workflow triggered by a merged PR, but the PR author is not a member of the docs-content team.");
37+
core.exportVariable('CONTINUE_WORKFLOW', 'false');
38+
}
39+
40+
- name: Post changelog instructions comment
41+
42+
if: env.CONTINUE_WORKFLOW == 'true'
43+
44+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
45+
with:
46+
github-token: ${{ secrets.DOCS_BOT_PAT_BASE }}
47+
script: |
48+
// Get PR author username
49+
const pr = context.payload.pull_request;
50+
const prAuthor = pr.user.login;
51+
52+
// Compose the comment body with readable YAML and correct formatting
53+
const commentBody =
54+
"👋 @" + prAuthor +
55+
" - Did this PR add noteworthy changes to the GitHub docs? If so, you might want to publicize this by adding an entry to " +
56+
"the [Docs changelog](https://github.com/github/docs-internal/blob/main/CHANGELOG.md).\n\n" +
57+
"To do this, type `/changelog` in a new comment on this PR and complete the fields.\n\n" +
58+
"A message will be posted to the **#docs-changelog** channel and a PR will be raised to update the [CHANGELOG.md](/CHANGELOG.md) file.";
59+
60+
// Post the comment
61+
await github.rest.issues.createComment({
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
issue_number: pr.number,
65+
body: commentBody
66+
});

0 commit comments

Comments
 (0)