Skip to content

Commit 91266c5

Browse files
authored
Merge branch 'main' into repo-sync
2 parents d5babbf + dd5ee52 commit 91266c5

6 files changed

Lines changed: 61 additions & 27 deletions

File tree

.github/actions-scripts/enable-automerge.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import { getOctokit } from '@actions/github'
2-
const token = process.env.GITHUB_TOKEN
3-
const prNumber = process.env.AUTOMERGE_PR_NUMBER
4-
const [org, repo] = process.env.GITHUB_REPOSITORY.split('/')
5-
const github = getOctokit(token)
62

73
main()
84
async function main() {
5+
const [org, repo] = process.env.GITHUB_REPOSITORY.split('/')
6+
if (!org || !repo) {
7+
throw new Error('GITHUB_REPOSITORY environment variable not set')
8+
}
9+
const prNumber = process.env.AUTOMERGE_PR_NUMBER
10+
if (!prNumber) {
11+
throw new Error(`AUTOMERGE_PR_NUMBER environment variable not set`)
12+
}
13+
const token = process.env.GITHUB_TOKEN
14+
if (!token) {
15+
throw new Error(`GITHUB_TOKEN environment variable not set`)
16+
}
17+
const github = getOctokit(token)
918
const pull = await github.rest.pulls.get({
1019
owner: org,
1120
repo: repo,

.github/actions-scripts/update-merge-queue-branch.js

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ const github = getOctokit(token)
2020
main()
2121

2222
async function main() {
23+
const [org, repo] = process.env.GITHUB_REPOSITORY.split('/')
24+
if (!org || !repo) {
25+
throw new Error('GITHUB_REPOSITORY environment variable not set')
26+
}
2327
// Get a list of open PRs and order them from oldest to newest
24-
const query = `query ($first: Int, $after: String, $firstLabels: Int) {
25-
organization(login: "github") {
26-
repository(name: "docs-internal") {
28+
const query = `query ($first: Int, $after: String, $firstLabels: Int, $repo: String!, $org: String!) {
29+
organization(login: $org) {
30+
repository(name: $repo) {
2731
pullRequests(first: $first, after: $after, states: OPEN, orderBy: {field: UPDATED_AT, direction: ASC}) {
2832
edges{
2933
node {
@@ -55,6 +59,8 @@ async function main() {
5559
}`
5660

5761
const queryVariables = {
62+
repo,
63+
org,
5864
first: 100,
5965
after: null, // when pagination in null it will get first page
6066
firstLabels: 100,
@@ -105,20 +111,25 @@ async function main() {
105111

106112
// Get the list of prs with the skip label so they can
107113
// be put at the beginning of the list
108-
const prioritizedPrList = autoMergeEnabledPRs
109-
.filter((pr) => pr.labels.includes('skip-to-front-of-merge-queue'))
110-
.concat(autoMergeEnabledPRs.filter((pr) => !pr.labels.includes('skip-to-front-of-merge-queue')))
114+
const prioritizedPrList = autoMergeEnabledPRs.sort(
115+
(a, b) =>
116+
Number(b.labels.includes('skip-to-front-of-merge-queue')) -
117+
Number(a.labels.includes('skip-to-front-of-merge-queue'))
118+
)
111119

112-
const nextInQueue = prioritizedPrList.shift()
113-
// Update the branch for the next PR in the merge queue
114-
github.rest.pulls.updateBranch({
115-
owner: 'github',
116-
repo: 'docs-internal',
117-
pull_number: parseInt(nextInQueue.number),
118-
})
120+
if (prioritizedPrList.length) {
121+
const nextInQueue = prioritizedPrList.shift()
122+
// Update the branch for the next PR in the merge queue
123+
github.rest.pulls.updateBranch({
124+
owner: org,
125+
repo,
126+
pull_number: nextInQueue.number,
127+
})
128+
console.log(`⏱ Total PRs in the merge queue: ${prioritizedPrList.length + 1}`)
129+
console.log(`🚂 Updated branch for PR #${JSON.stringify(nextInQueue, null, 2)}`)
130+
}
119131

120-
console.log(`⏱ Total PRs in the merge queue: ${prioritizedPrList.length + 1}`)
121-
console.log(`🚂 Updated branch for PR #${JSON.stringify(nextInQueue, null, 2)}`)
122-
console.log(`🚏 Next up in the queue: `)
123-
console.log(JSON.stringify(prioritizedPrList, null, 2))
132+
prioritizedPrList.length
133+
? console.log(`🚏 Next up in the queue: \n ${JSON.stringify(prioritizedPrList, null, 2)}`)
134+
: console.log(`⚡ The merge queue is empty`)
124135
}

.github/workflows/autoupdate-branch.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ jobs:
3030
name: autoupdate
3131
runs-on: ubuntu-latest
3232
steps:
33+
- name: Check out repo content
34+
uses: actions/checkout@1e204e9a9253d643386038d443f96446fa156a97
35+
36+
- name: Setup Node
37+
uses: actions/setup-node@270253e841af726300e85d718a5f606959b2903c
38+
with:
39+
node-version: 16.13.x
40+
cache: npm
41+
3342
- name: Update next PR in queue
3443
env:
3544
GITHUB_TOKEN: ${{ secrets.DOCUBOT_REPO_PAT }}

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@primer/css": "^18.2.0",
1717
"@primer/octicons": "^16.1.1",
1818
"@primer/octicons-react": "^16.1.1",
19+
"@react-aria/ssr": "^3.1.0",
1920
"accept-language-parser": "^1.5.0",
2021
"ajv": "^8.7.1",
2122
"ajv-formats": "^2.1.1",

pages/_app.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import App from 'next/app'
33
import type { AppProps, AppContext } from 'next/app'
44
import Head from 'next/head'
55
import { useTheme, ThemeProvider } from '@primer/components'
6+
import { SSRProvider } from '@react-aria/ssr'
67
import { defaultComponentThemeProps, getThemeProps } from 'components/lib/getThemeProps'
78

89
import '../stylesheets/index.scss'
@@ -43,12 +44,14 @@ const MyApp = ({ Component, pageProps, csrfToken, themeProps, languagesContext }
4344

4445
<meta name="csrf-token" content={csrfToken} />
4546
</Head>
46-
<ThemeProvider dayScheme={themeProps.dayTheme} nightScheme={themeProps.nightTheme}>
47-
<LanguagesContext.Provider value={languagesContext}>
48-
<SetTheme themeProps={themeProps} />
49-
<Component {...pageProps} />
50-
</LanguagesContext.Provider>
51-
</ThemeProvider>
47+
<SSRProvider>
48+
<ThemeProvider dayScheme={themeProps.dayTheme} nightScheme={themeProps.nightTheme}>
49+
<LanguagesContext.Provider value={languagesContext}>
50+
<SetTheme themeProps={themeProps} />
51+
<Component {...pageProps} />
52+
</LanguagesContext.Provider>
53+
</ThemeProvider>
54+
</SSRProvider>
5255
</>
5356
)
5457
}

0 commit comments

Comments
 (0)