Skip to content

Commit dca73aa

Browse files
committed
Merge branch 'check-links-improvement-redux' of github.com:github/docs-internal into check-links-improvement-redux
2 parents 8d84a90 + 4cf811f commit dca73aa

2,987 files changed

Lines changed: 51293 additions & 10378 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/allowed-actions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ module.exports = [
2525
'pascalgn/automerge-action@c9bd182',
2626
'peter-evans/create-issue-from-file@a04ce672e3acedb1f8e416b46716ddfd09905326',
2727
'peter-evans/create-or-update-comment@5221bf4aa615e5c6e95bb142f9673a9c791be2cd',
28-
'peter-evans/create-pull-request@938e6aea6f8dbdaced2064e948cb806c77fe87b8',
28+
'peter-evans/create-pull-request@8c603dbb04b917a9fc2dd991dc54fef54b640b43',
2929
'rachmari/actions-add-new-issue-to-column@1a459ef92308ba7c9c9dc2fcdd72f232495574a9',
3030
'rachmari/labeler@832d42ec5523f3c6d46e8168de71cd54363e3e2e',
3131
'repo-sync/github-sync@3832fe8e2be32372e1b3970bbae8e7079edeec88',
3232
'repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d',
3333
'someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd',
3434
'tjenkinson/gh-action-auto-merge-dependency-updates@cee2ac0',
35-
'EndBug/add-and-commit@9358097a71ad9fb9e2f9624c6098c89193d83575'
35+
'EndBug/add-and-commit@9358097a71ad9fb9e2f9624c6098c89193d83575',
36+
'dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58'
3637
]

.github/workflows/close-unwanted-pull-requests.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/codeql.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: CodeQL analysis
22

33
on:
44
push:
5+
branches: main
6+
pull_request:
7+
branches: main
58
paths:
69
- '**/*.js'
710
- '.github/workflows/codeql.yml'
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
- id: membership_check
21+
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
22+
with:
23+
github-token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
24+
script: |
25+
// Only perform this action with GitHub employees
26+
try {
27+
await github.teams.getMembershipForUserInOrg({
28+
org: 'github',
29+
team_slug: 'employees',
30+
username: context.payload.sender.login,
31+
});
32+
} catch(err) {
33+
// An error will be thrown if the user is not a GitHub employee
34+
// If a user is not a GitHub employee, we should stop here and
35+
// Not send a notification
36+
return
37+
}
38+
39+
// Don't perform this action with Docs team members
40+
try {
41+
await github.teams.getMembershipForUserInOrg({
42+
org: 'github',
43+
team_slug: 'docs',
44+
username: context.payload.sender.login,
45+
});
46+
// If the user is a Docs team member, we should stop here and not send
47+
// a notification
48+
return
49+
} catch(err) {
50+
// An error will be thrown if the user is not a Docs team member
51+
// If a user is not a Docs team member we should continue and send
52+
// the notification
53+
}
54+
55+
const issueNo = context.number || context.issue.number
56+
57+
// Create an issue in our private repo
58+
await github.issues.create({
59+
owner: 'github',
60+
repo: 'docs-internal',
61+
title: `@${context.payload.sender.login} confirm that \#${issueNo} should be in the public github/docs repo`,
62+
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`
63+
});
64+
65+
core.setOutput('did_warn', 'true')
66+
67+
- name: Send Slack notification if a GitHub employee who isn't on the docs team opens an issue in public
68+
if: ${{ steps.membership_check.outputs.did_warn && github.repository == 'github/docs' }}
69+
uses: someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd
70+
with:
71+
channel: ${{ secrets.DOCS_OPEN_SOURCE_SLACK_CHANNEL_ID }}
72+
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
73+
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.

.github/workflows/remove-unused-assets.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Remove script results file
3434
run: rm -rf ./results.md
3535
- name: Create pull request
36-
uses: peter-evans/create-pull-request@938e6aea6f8dbdaced2064e948cb806c77fe87b8
36+
uses: peter-evans/create-pull-request@8c603dbb04b917a9fc2dd991dc54fef54b640b43
3737
with:
3838
# need to use a token with repo and workflow scopes for this step
3939
token: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}

.github/workflows/repo-sync-stalls.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Repo Sync Stalls
22
on:
33
workflow_dispatch:
44
schedule:
5-
- cron: '*/30 * * * *'
5+
- cron: '0 */2 * * *'
66
jobs:
77
check-freezer:
88
name: Check for deployment freezes
@@ -40,7 +40,7 @@ jobs:
4040
const timeDelta = Date.now() - Date.parse(pr.created_at);
4141
const minutesOpen = timeDelta / 1000 / 60;
4242
43-
if (minutesOpen > 30) {
43+
if (minutesOpen > 180) {
4444
core.setFailed('Repo sync appears to be stalled')
4545
}
4646
})

.github/workflows/repo-sync.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
name: Repo Sync
88

99
on:
10+
workflow_dispatch:
1011
schedule:
1112
- cron: '*/15 * * * *' # every 15 minutes
1213

@@ -51,7 +52,7 @@ jobs:
5152
destination_branch: main
5253
pr_title: 'repo sync'
5354
pr_body: "This is an automated pull request to sync changes between the public and private repos.\n\n:robot: This pull request should be merged (not squashed) to preserve continuity across repos, so please let a bot do the merging!"
54-
pr_label: automerge,autoupdate
55+
pr_label: automerge,autoupdate,automated-reposync-pr
5556
github_token: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}
5657

5758
- name: Find pull request
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Check unallowed file changes
2+
3+
on:
4+
pull_request_target:
5+
paths:
6+
- '.github/workflows/**'
7+
- '.github/CODEOWNERS'
8+
- 'translations/**'
9+
- 'assets/fonts/**'
10+
- 'data/graphql/**'
11+
- 'lib/graphql/**'
12+
- 'lib/redirects/**'
13+
- 'lib/rest/**'
14+
- 'lib/webhooks/**'
15+
16+
jobs:
17+
triage:
18+
if: github.repository == 'github/docs' && github.event.pull_request.user.login != 'Octomerger'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
22+
- name: Check for existing requested changes
23+
id: requested-change
24+
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
25+
with:
26+
github-token: ${{secrets.GITHUB_TOKEN}}
27+
result-encoding: json
28+
script: |
29+
const pullReviews = await github.pulls.listReviews({
30+
...context.repo,
31+
pull_number: context.payload.number
32+
})
33+
34+
const botReviews = pullReviews.data
35+
.filter(review => review.user.login === 'github-actions[bot]')
36+
.sort((a, b) => new Date(b.submitted_at) - new Date(a.submitted_at))
37+
.shift()
38+
39+
if (botReviews) {
40+
console.log(`Pull request reviews authored by the github-action bot: ${botReviews}`)
41+
}
42+
return botReviews
43+
44+
- name: Get files changed
45+
uses: dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58
46+
id: filter
47+
with:
48+
# Base branch used to get changed files
49+
base: 'main'
50+
51+
# Enables setting an output in the format in `${FILTER_NAME}_files
52+
# with the names of the matching files formatted as JSON array
53+
list-files: json
54+
55+
# Returns list of changed files matching each filter
56+
filters: |
57+
translation:
58+
- 'translations/**'
59+
openapi:
60+
- 'lib/rest/static/**'
61+
notAllowed:
62+
- '.github/workflows/**'
63+
- '.github/CODEOWNERS'
64+
- 'translations/**'
65+
- 'assets/fonts/**'
66+
- 'data/graphql/**'
67+
- 'lib/graphql/**'
68+
- 'lib/redirects/**'
69+
- 'lib/rest/**'
70+
- 'lib/webhooks/**'
71+
72+
# When there are changes to files we can't accept
73+
# and no review exists,leave a REQUEST_CHANGES review
74+
- name: Request pull request changes
75+
# Check for no reviews or reviews that aren't CHANGES_REQUESTED
76+
if: ${{ steps.filter.outputs.notAllowed == 'true' && (!steps.requested-change.outputs.result || fromJson(steps.requested-change.outputs.result).state != 'CHANGES_REQUESTED') }}
77+
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
78+
with:
79+
github-token: ${{secrets.GITHUB_TOKEN}}
80+
script: |
81+
const changedFiles = ${{steps.filter.outputs.notAllowed_files}}
82+
const restFiles = ${{steps.filter.outputs.openapi_files}}
83+
const translationFiles = ${{steps.filter.outputs.translation_files}}
84+
const markdownFiles = changedFiles.map(file => `- \`${file}\`\n`).join('')
85+
86+
let reviewMessage = `👋 Hey there spelunker. It looks like you've modified some files that we can't accept as contributions.\n${markdownFiles}\n\nYou'll need to revert all of these ☝️ files using [GitHub Desktop](https://docs.github.com/en/free-pro-team@latest/desktop/contributing-and-collaborating-using-github-desktop/reverting-a-commit) or \`git checkout origin/main <file name>\`. Once you get those files reverted, we can continue with the review process. :octocat:`
87+
88+
if (restFiles.length > 0) {
89+
reviewMessage += "\n\nIt looks like you've modified the OpenAPI schema (`lib/rest/static/**`). While we aren't accepting changes to the schema directly, you can open an issue for any updates to the REST API docs. Head on over to the [`github/rest-api-description`](https://github.com/github/rest-api-description/issues/new?assignees=&labels=Inaccuracy&template=schema-inaccuracy.md&title=%5BSchema+Inaccuracy%5D+%3CDescribe+Problem%3E) repository to open an issue. ⚡"
90+
}
91+
92+
if (translationFiles.length > 0) {
93+
await github.issues.addLabels({
94+
...context.repo,
95+
issue_number: context.payload.number,
96+
labels: ['localization']
97+
})
98+
reviewMessage += "\n\nIt looks like you've modified translated content. Unfortunately, we are not able to accept pull requests for translated content. Our translation process involves an integration with an external service at crowdin.com, where all translation activity happens. We hope to eventually open up the translation process to the open source community, but we're not there yet. See https://github.com/github/docs/blob/main/CONTRIBUTING.md#earth_asia-translations for more details."
99+
}
100+
101+
await github.pulls.createReview({
102+
...context.repo,
103+
pull_number: context.payload.number,
104+
body: reviewMessage,
105+
event: 'REQUEST_CHANGES'
106+
})
107+
# When the most recent review was CHANGES_REQUESTED and the existing
108+
# PR no longer contains unallowed changes, dismiss the previous review
109+
- name: Dismiss pull request review
110+
# Check that unallowed files aren't modified and that a
111+
# CHANGES_REQUESTED review already exists
112+
if: ${{ steps.filter.outputs.notAllowed == 'false' && steps.requested-change.outputs.result && fromJson(steps.requested-change.outputs.result).state == 'CHANGES_REQUESTED' }}
113+
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
114+
with:
115+
github-token: ${{secrets.GITHUB_TOKEN}}
116+
script: |
117+
await github.pulls.dismissReview({
118+
...context.repo,
119+
pull_number: context.payload.number,
120+
review_id: ${{fromJson(steps.requested-change.outputs.result).id}},
121+
message: `✨Looks like you reverted all files we don't accept contributions for. 🙌 A member of the docs team will review your PR soon. 🚂`
122+
})

.github/workflows/update-graphql-files.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ env:
99
FREEZE: ${{ secrets.FREEZE }}
1010

1111
on:
12+
workflow_dispatch:
1213
schedule:
1314
- cron: '20 16 * * *' # run every day at 16:20 UTC / 8:20 PST
1415

@@ -36,15 +37,15 @@ jobs:
3637
- name: Run updater scripts
3738
env:
3839
# need to use a token from a user with access to github/github for this step
39-
GITHUB_TOKEN: ${{ secrets.ZEKE_PAT_WITH_REPO_AND_WORKFLOW_SCOPE_FOR_REPO_SYNC }}
40+
GITHUB_TOKEN: ${{ secrets.RACHMARI_REPO_WORKFLOW }}
4041
run: |
4142
script/graphql/update-files.js
4243
- name: Create pull request
4344
id: create-pull-request
44-
uses: peter-evans/create-pull-request@938e6aea6f8dbdaced2064e948cb806c77fe87b8
45+
uses: peter-evans/create-pull-request@8c603dbb04b917a9fc2dd991dc54fef54b640b43
4546
with:
4647
# need to use a token with repo and workflow scopes for this step
47-
token: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}
48+
token: ${{ secrets.GITHUB_TOKEN }}
4849
commit-message: 'Action ran graphql script"update-files"'
4950
title: GraphQL schema update
5051
body:

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "attach",
7+
"name": "Node: Nodemon",
8+
"processId": "${command:PickProcess}",
9+
"restart": true,
10+
"protocol": "inspector",
11+
},
12+
]
13+
}

0 commit comments

Comments
 (0)