Skip to content

Commit 15b0585

Browse files
authored
Merge pull request #13707 from github/repo-sync
repo sync
2 parents 045d909 + 40d6221 commit 15b0585

17 files changed

Lines changed: 1233 additions & 1254 deletions

File tree

.github/actions-scripts/fr-add-docs-reviewers-requests.js

Lines changed: 97 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -8,88 +8,83 @@ import {
88
generateUpdateProjectNextItemFieldMutation,
99
} from './projects.js'
1010

11-
async function run() {
12-
// Get info about the docs-content review board project
13-
// and about open github/github PRs
14-
const data = await graphql(
15-
`
16-
query ($organization: String!, $repo: String!, $projectNumber: Int!, $num_prs: Int!) {
17-
organization(login: $organization) {
18-
projectNext(number: $projectNumber) {
19-
id
20-
items(last: 100) {
11+
async function getAllOpenPRs() {
12+
let prsRemaining = true
13+
let cursor
14+
let prData = []
15+
while (prsRemaining) {
16+
const data = await graphql(
17+
`
18+
query ($organization: String!, $repo: String!) {
19+
repository(name: $repo, owner: $organization) {
20+
pullRequests(last: 100, states: OPEN${cursor ? ` before:"${cursor}"` : ''}) {
21+
pageInfo{startCursor, hasPreviousPage},
2122
nodes {
2223
id
23-
}
24-
}
25-
fields(first: 20) {
26-
nodes {
27-
id
28-
name
29-
settings
30-
}
31-
}
32-
}
33-
}
34-
repository(name: $repo, owner: $organization) {
35-
pullRequests(last: $num_prs, states: OPEN) {
36-
nodes {
37-
id
38-
isDraft
39-
reviewRequests(first: 10) {
40-
nodes {
41-
requestedReviewer {
42-
... on Team {
43-
name
24+
isDraft
25+
reviewRequests(first: 10) {
26+
nodes {
27+
requestedReviewer {
28+
... on Team {
29+
name
30+
}
4431
}
4532
}
4633
}
47-
}
48-
labels(first: 5) {
49-
nodes {
50-
name
34+
labels(first: 5) {
35+
nodes {
36+
name
37+
}
5138
}
52-
}
53-
reviews(first: 10) {
54-
nodes {
55-
onBehalfOf(first: 1) {
56-
nodes {
57-
name
39+
reviews(first: 10) {
40+
nodes {
41+
onBehalfOf(first: 1) {
42+
nodes {
43+
name
44+
}
5845
}
5946
}
6047
}
61-
}
62-
author {
63-
login
48+
author {
49+
login
50+
}
6451
}
6552
}
6653
}
6754
}
55+
`,
56+
{
57+
organization: process.env.ORGANIZATION,
58+
repo: process.env.REPO,
59+
headers: {
60+
authorization: `token ${process.env.TOKEN}`,
61+
},
6862
}
69-
`,
70-
{
71-
organization: process.env.ORGANIZATION,
72-
repo: process.env.REPO,
73-
projectNumber: parseInt(process.env.PROJECT_NUMBER),
74-
num_prs: parseInt(process.env.NUM_PRS),
75-
headers: {
76-
authorization: `token ${process.env.TOKEN}`,
77-
'GraphQL-Features': 'projects_next_graphql',
78-
},
79-
}
80-
)
63+
)
64+
65+
prsRemaining = data.repository.pullRequests.pageInfo.hasPreviousPage
66+
cursor = data.repository.pullRequests.pageInfo.startCursor
67+
prData = [...prData, ...data.repository.pullRequests.nodes]
68+
}
69+
70+
return prData
71+
}
72+
73+
async function run() {
74+
// Get info about open github/github PRs
75+
const prData = await getAllOpenPRs()
8176

8277
// Get the PRs that are:
8378
// - not draft
8479
// - not a train
8580
// - are requesting a review by docs-reviewers
8681
// - have not already been reviewed on behalf of docs-reviewers
87-
const prs = data.repository.pullRequests.nodes.filter(
82+
const prs = prData.filter(
8883
(pr) =>
8984
!pr.isDraft &&
9085
!pr.labels.nodes.find((label) => label.name === 'Deploy train 🚂') &&
9186
pr.reviewRequests.nodes.find(
92-
(requestedReviewers) => requestedReviewers.requestedReviewer.name === process.env.REVIEWER
87+
(requestedReviewers) => requestedReviewers.requestedReviewer?.name === process.env.REVIEWER
9388
) &&
9489
!pr.reviews.nodes
9590
.flatMap((review) => review.onBehalfOf.nodes)
@@ -104,28 +99,60 @@ async function run() {
10499
const prAuthors = prs.map((pr) => pr.author.login)
105100
console.log(`PRs found: ${prIDs}`)
106101

102+
// Get info about the docs-content review board project
103+
const projectData = await graphql(
104+
`
105+
query ($organization: String!, $projectNumber: Int!) {
106+
organization(login: $organization) {
107+
projectNext(number: $projectNumber) {
108+
id
109+
items(last: 100) {
110+
nodes {
111+
id
112+
}
113+
}
114+
fields(first: 100) {
115+
nodes {
116+
id
117+
name
118+
settings
119+
}
120+
}
121+
}
122+
}
123+
}
124+
`,
125+
{
126+
organization: process.env.ORGANIZATION,
127+
projectNumber: parseInt(process.env.PROJECT_NUMBER),
128+
headers: {
129+
authorization: `token ${process.env.TOKEN}`,
130+
},
131+
}
132+
)
133+
107134
// Get the project ID
108-
const projectID = data.organization.projectNext.id
135+
const projectID = projectData.organization.projectNext.id
109136

110137
// Get the IDs of the last 100 items on the board.
111138
// Until we have a way to check from a PR whether the PR is in a project,
112139
// this is how we (roughly) avoid overwriting PRs that are already on the board.
113140
// If we are overwriting items, query for more items.
114-
const existingItemIDs = data.organization.projectNext.items.nodes.map((node) => node.id)
141+
const existingItemIDs = projectData.organization.projectNext.items.nodes.map((node) => node.id)
115142

116143
// Get the ID of the fields that we want to populate
117-
const datePostedID = findFieldID('Date posted', data)
118-
const reviewDueDateID = findFieldID('Review due date', data)
119-
const statusID = findFieldID('Status', data)
120-
const featureID = findFieldID('Feature', data)
121-
const contributorTypeID = findFieldID('Contributor type', data)
122-
const sizeTypeID = findFieldID('Size', data)
123-
const authorID = findFieldID('Contributor', data)
144+
const datePostedID = findFieldID('Date posted', projectData)
145+
const reviewDueDateID = findFieldID('Review due date', projectData)
146+
const statusID = findFieldID('Status', projectData)
147+
const featureID = findFieldID('Feature', projectData)
148+
const contributorTypeID = findFieldID('Contributor type', projectData)
149+
const sizeTypeID = findFieldID('Size', projectData)
150+
const authorID = findFieldID('Contributor', projectData)
124151

125152
// Get the ID of the single select values that we want to set
126-
const readyForReviewID = findSingleSelectID('Ready for review', 'Status', data)
127-
const hubberTypeID = findSingleSelectID('Hubber or partner', 'Contributor type', data)
128-
const docsMemberTypeID = findSingleSelectID('Docs team', 'Contributor type', data)
153+
const readyForReviewID = findSingleSelectID('Ready for review', 'Status', projectData)
154+
const hubberTypeID = findSingleSelectID('Hubber or partner', 'Contributor type', projectData)
155+
const docsMemberTypeID = findSingleSelectID('Docs team', 'Contributor type', projectData)
129156

130157
// Add the PRs to the project
131158
const itemIDs = await addItemsToProject(prIDs, projectID)

.github/actions-scripts/projects.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,29 @@ export async function isDocsTeamMember(login) {
114114
return teamMembers.includes(login)
115115
}
116116

117+
// Given a GitHub login, returns a bool indicating
118+
// whether the login is part of the GitHub org
119+
export async function isGitHubOrgMember(login) {
120+
const data = await graphql(
121+
`
122+
query {
123+
user(login: "${login}") {
124+
organization(login: "github"){
125+
name
126+
}
127+
}
128+
}
129+
`,
130+
{
131+
headers: {
132+
authorization: `token ${process.env.TOKEN}`,
133+
},
134+
}
135+
)
136+
137+
return Boolean(data.user.organization)
138+
}
139+
117140
// Formats a date object into the required format for projects
118141
export function formatDateForProject(date) {
119142
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
@@ -246,6 +269,7 @@ export default {
246269
addItemsToProject,
247270
addItemToProject,
248271
isDocsTeamMember,
272+
isGitHubOrgMember,
249273
findFieldID,
250274
findSingleSelectID,
251275
formatDateForProject,

.github/actions-scripts/ready-for-docs-review.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { graphql } from '@octokit/graphql'
33
import {
44
addItemToProject,
55
isDocsTeamMember,
6+
isGitHubOrgMember,
67
findFieldID,
78
findSingleSelectID,
89
generateUpdateProjectNextItemFieldMutation,
@@ -178,9 +179,12 @@ async function run() {
178179
let contributorType
179180
if (await isDocsTeamMember(process.env.AUTHOR_LOGIN)) {
180181
contributorType = docsMemberTypeID
182+
} else if (await isGitHubOrgMember(process.env.AUTHOR_LOGIN)) {
183+
contributorType = hubberTypeID
181184
} else if (process.env.REPO === 'github/docs') {
182185
contributorType = osContributorTypeID
183186
} else {
187+
// use hubber as the fallback so that the PR doesn't get lost on the board
184188
contributorType = hubberTypeID
185189
}
186190

.github/allowed-actions.js

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

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
runs-on: ubuntu-latest
3232
steps:
3333
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
34-
- uses: github/codeql-action/init@v1
34+
- uses: github/codeql-action/init@5f532563584d71fdef14ee64d17bafb34f751ce5
3535
with:
3636
languages: javascript # comma separated list of values from {go, python, javascript, java, cpp, csharp} (not YET ruby, sorry!)
37-
- uses: github/codeql-action/analyze@v1
37+
- uses: github/codeql-action/analyze@5f532563584d71fdef14ee64d17bafb34f751ce5
3838
continue-on-error: true

.github/workflows/docs-review-collect.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,3 @@ jobs:
4040
ORGANIZATION: 'github'
4141
REPO: 'github'
4242
REVIEWER: 'docs-reviewers'
43-
# This is an educated guess of how many PRs are opened in a day on the github/github repo
44-
# If we are missing PRs, either increase this number or increase the frequency at which this script is run
45-
NUM_PRS: 100

.github/workflows/staging-build-and-deploy-pr.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ name: Staging - Build and Deploy PR (fast and private-only)
66

77
# This whole workflow is only guaranteed to be secure in the *private
88
# repo* and because we repo-sync these files over the to the public one,
9-
# IT'S CRUCIALLY IMPORTANT THAT THIS WORKFLOW IS ONLY ENABLED IN docs-internal!
9+
# IT'S IMPORTANT THAT THIS WORKFLOW IS ONLY ENABLED IN docs-internal!
1010

1111
on:
12-
# Ideally, we'd like to use 'pull_request' because we can more easily
13-
# test changes to this workflow without relying on merges to 'main'.
14-
# But this is guaranteed to be safer and won't have the problem of
15-
# necessary secrets not being available.
16-
# Perhaps some day when we're confident this workflow will always
17-
# work in a regular PR, we can switch to that.
18-
pull_request_target:
12+
# The advantage of 'pull_request' over 'pull_request_target' is that we
13+
# can make changes to this file and test them in a pull request, instead
14+
# of relying on landing it in 'main' first.
15+
# From a security point of view, its arguably safer this way because
16+
# unlike 'pull_request_target', these only have secrets if the pull
17+
# request creator has permission to access secrets.
18+
pull_request:
1919

2020
permissions:
2121
actions: read

content/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ env:
8585
# permission can be added at job level or workflow level
8686
permissions:
8787
id-token: write
88-
contents: read # This is required for actions/checkout@v1
88+
contents: read # This is required for actions/checkout@v2
8989
jobs:
9090
S3PackageUpload:
9191
runs-on: ubuntu-latest
9292
steps:
9393
- name: Git clone the repository
94-
uses: actions/checkout@v1
94+
uses: actions/checkout@v2
9595
- name: configure aws credentials
9696
uses: aws-actions/configure-aws-credentials@master
9797
with:

content/actions/monitoring-and-troubleshooting-workflows/adding-a-workflow-status-badge.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ This Markdown example adds a status badge for a branch with the name `feature-1`
3939

4040
## Using the `event` parameter
4141

42-
This Markdown example adds a badge that displays the status of workflow runs triggered by the `pull_request` event.
42+
This Markdown example adds a badge that displays the status of workflow runs triggered by the `push` event, which will show the status of the build for the current state of that branch.
4343

4444
```markdown
45-
![example event parameter](https://github.com/github/docs/actions/workflows/main.yml/badge.svg?event=pull_request)
45+
![example event parameter](https://github.com/github/docs/actions/workflows/main.yml/badge.svg?event=push)
4646
```

content/actions/using-github-hosted-runners/about-github-hosted-runners.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ For more information, see "[Viewing workflow run history](/actions/managing-work
7676

7777
For the overall list of included tools for each runner operating system, see the links below:
7878

79-
* [Ubuntu 20.04 LTS](https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md)
80-
* [Ubuntu 18.04 LTS](https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md)
79+
* [Ubuntu 20.04 LTS](https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md)
80+
* [Ubuntu 18.04 LTS](https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-Readme.md)
8181
* [Windows Server 2022](https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md)
8282
* [Windows Server 2019](https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md)
8383
* [Windows Server 2016](https://github.com/actions/virtual-environments/blob/main/images/win/Windows2016-Readme.md)

0 commit comments

Comments
 (0)