Skip to content

Commit 712dd75

Browse files
chiedojaniceileneJamesMGreeneJasonEtco
authored
Confirm w/ internal GitHub team members when they post to docs (#16804)
Confirm w/ internal GitHub team members when they post to docs Co-authored-by: Chiedo <chiedo@users.noreply.github.com> Co-authored-by: Janice <janiceilene@github.com> Co-authored-by: James M. Greene <JamesMGreene@github.com> Co-authored-by: Jason Etcovitch <jasonetco@github.com>
1 parent a97698f commit 712dd75

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Confirm internal staff meant to post in public
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
- reopened
8+
- transferred
9+
pull_request_target:
10+
types:
11+
- opened
12+
- reopened
13+
14+
jobs:
15+
check-team-membership:
16+
runs-on: ubuntu-latest
17+
continue-on-error: true
18+
if: github.repository == 'github/docs'
19+
steps:
20+
- uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
21+
with:
22+
github-token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
23+
script: |
24+
// Only perform this action with GitHub employees
25+
try {
26+
await github.teams.getMembershipForUserInOrg({
27+
org: 'github',
28+
team_slug: 'employees',
29+
username: context.payload.sender.login,
30+
});
31+
} catch(err) {
32+
// An error will be thrown if the user is not a GitHub employee
33+
// If a user is not a GitHub employee, we should stop here and
34+
// Not send a notification
35+
return
36+
}
37+
38+
// Don't perform this action with Docs team members
39+
try {
40+
await github.teams.getMembershipForUserInOrg({
41+
org: 'github',
42+
team_slug: 'docs',
43+
username: context.payload.sender.login,
44+
});
45+
// If the user is a Docs team member, we should stop here and not send
46+
// a notification
47+
return
48+
} catch(err) {
49+
// An error will be thrown if the user is not a Docs team member
50+
// If a user is not a Docs team member we should continue and send
51+
// the notification
52+
}
53+
54+
const issueNo = context.number || context.issue.number
55+
56+
// Create an issue in our private repo
57+
await github.issues.create({
58+
owner: 'github',
59+
repo: 'docs-internal',
60+
title: `@${context.payload.sender.login} confirm that \#${issueNo} should be in the public github/docs repo`,
61+
body: `@${context.payload.sender.login} opened https://github.com/github/docs/issues/${issueNo} publicly in the github/docs repo, instead of the private github/docs-internal repo.\n\n@${context.payload.sender.login}, please confirm that this belongs in the public repo and that no sensitive information was disclosed by commenting below and closing the issue.\n\nIf this was not intentional and sensitive information was shared, please delete https://github.com/github/docs/issues/${issueNo} and notify us in the \#docs-open-source channel.\n\nThanks! \n\n/cc @github/docs @github/docs-engineering`
62+
});
63+
64+
throw new Error('A Hubber opened an issue on the public github/docs repo');
65+
66+
- name: Send Slack notification if a GitHub employee who isn't on the docs team opens an issue in public
67+
if: ${{ failure() && github.repository == 'github/docs' }}
68+
uses: someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd
69+
with:
70+
channel: ${{ secrets.DOCS_OPEN_SOURCE_SLACK_CHANNEL_ID }}
71+
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
72+
text: <@${{github.actor}}> opened https://github.com/github/docs/issues/${{ github.event.number || github.event.issue.number }} publicly on the github/docs repo instead of the private github/docs-internal repo. They have been notified via a new issue in the github/docs-internal repo to confirm this was intentional.

0 commit comments

Comments
 (0)