Skip to content

Commit 634e3b3

Browse files
authored
Merge branch 'main' into jules-6323
2 parents 729a8d1 + adfb7b7 commit 634e3b3

File tree

579 files changed

+10816
-5539
lines changed

Some content is hidden

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

579 files changed

+10816
-5539
lines changed

.github/actions-scripts/openapi-schema-branch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const changedFiles = execSync('git diff --name-only HEAD').toString()
3636
if (changedFiles !== '') {
3737
console.log(`These files were changed:\n${changedFiles}`)
3838
console.log(
39-
`🚧⚠️ Your decorated and dereferenced schema files don't match. Ensure you're using decorated and dereferenced schemas from the automatically created pull requests by the 'github-openapi-bot' user. \n\n If this test is failing after updates to the script/rest directory, run script/rest/update-files.js --decorate-only to re-generate the decorated files from the existing dereferenced files and check those in. \n\n If this test is failing after an update to a package, check the changes the new package makes to the decorated files by running script/rest/update-files.js --decorate-only. If the changes are small style changes that don't impact the overall experience, check the updated decorated file in. Otherwise, more work may be needed to be compatible with the updated package. \n\n For more information, see 'script/rest/README.md'. 🛑`
39+
`🚧⚠️ Your decorated and dereferenced schema files don't match. Ensure you're using decorated and dereferenced schemas from the automatically created pull requests by the 'github-openapi-bot' user. \n\n If this test is failing after updates to the script/rest directory, run script/rest/update-files.js --decorate-only to re-generate the decorated files from the existing dereferenced files and check those in. \n\n If this test is failing after an update to a package, check the changes the new package makes to the decorated files by running script/rest/update-files.js --decorate-only.\n\nIf you updated script/rest/utils/rest-api-overrides.json, you'll need to run script/rest/update-files.js --decorate-only to regenerate the decorated file and redirects file (check in the changed lib/rest/static/decorated files).\n\nIf the changes are small style changes that don't impact the overall experience, check the updated decorated file in. Otherwise, more work may be needed to be compatible with the updated package. \n\n For more information, see 'script/rest/README.md'. 🛑`
4040
)
4141
process.exit(1)
4242
}

.github/workflows/optimize-images.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,47 @@ name: Optimize images
66

77
on:
88
workflow_dispatch:
9-
schedule:
10-
- cron: '45 17 * * 2' # Run Tuesdays at 17:45 UTC / 9:45 PST
9+
pull_request:
10+
paths:
11+
- '**/*.png'
1112

1213
permissions:
1314
contents: write
1415
pull-requests: write
1516

1617
jobs:
17-
optimize-images:
18-
if: github.repository == 'github/docs-internal'
18+
optimize-images-on-pr:
19+
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
1920
runs-on: ubuntu-latest
2021
steps:
21-
- name: Check out repo
22+
- name: Check out repo on head ref
2223
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
24+
with:
25+
ref: ${{ github.head_ref }}
26+
27+
- name: Check out base ref
28+
run: git fetch --no-tags --depth=1 origin $GITHUB_BASE_REF
2329

2430
- name: Install the Optipng package
2531
run: sudo apt-get update && sudo apt-get -y install optipng
2632

27-
- name: Run the Optipng package
28-
run: find . -name '*.png' -print0 | xargs -0 optipng -nx
33+
- name: Run optipng on new or changed images
34+
run: |
35+
set -e # exit when any command fails
36+
37+
echo "Ensure we can view $GITHUB_BASE_REF"
38+
git checkout $GITHUB_BASE_REF
39+
40+
echo "Ensure we can view $GITHUB_HEAD_REF"
41+
git checkout $GITHUB_HEAD_REF
2942

30-
- name: Make a branch, commit, push, and pull request
43+
echo "List the files that changed"
44+
git diff --name-only $GITHUB_HEAD_REF $GITHUB_BASE_REF
45+
46+
echo "Run optipng on pngs in from the diff"
47+
git diff --name-only -z $GITHUB_HEAD_REF $GITHUB_BASE_REF -- '*.png' | xargs -0 optipng -nx
48+
49+
- name: Make a commit and a push
3150
run: |
3251
echo "If there's no changes, exit"
3352
if [[ ! `git status --porcelain` ]]
@@ -36,20 +55,13 @@ jobs:
3655
exit 0
3756
fi
3857

39-
echo "Make a new branch"
40-
BRANCH="optimize-images-$(date +'%Y%m%d%H%M%S')"
41-
git checkout -b $BRANCH
42-
4358
echo "Make a commit"
4459
git config user.name github-actions
4560
git config user.email [email protected]
4661
git add "*.png"
4762
git commit --message="Optimize images"
4863

4964
echo "Push up changes"
50-
git push --set-upstream origin $BRANCH
51-
52-
echo "Open a pull request"
53-
gh pr create --title "Optimize images" --body "Optimize images"
65+
git push
5466
env:
5567
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/triage-unallowed-contributions.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ on:
2121
- 'package*.json'
2222
- 'script/**'
2323
- 'translations/**'
24+
- 'content/actions/deployment/security-hardening-your-deployments/**'
2425

2526
permissions:
2627
pull-requests: write
@@ -67,6 +68,7 @@ jobs:
6768
- 'package*.json'
6869
- 'scripts/**'
6970
- 'translations/**'
71+
- 'content/actions/deployment/security-hardening-your-deployments/**'
7072

7173
# When there are changes to files we can't accept, leave a comment
7274
# explaining this to the PR author
@@ -90,6 +92,7 @@ jobs:
9092
'package*.json',
9193
'scripts/**',
9294
'translations/**',
95+
'content/actions/deployment/security-hardening-your-deployments/**',
9396
]
9497

9598
const badFiles = badFilesArr.join('\n')
Binary file not shown.
18.6 KB
Loading

components/DefaultLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { SmallFooter } from 'components/page-footer/SmallFooter'
66
import { ScrollButton } from 'components/ui/ScrollButton'
77
import { SupportSection } from 'components/page-footer/SupportSection'
88
import { DeprecationBanner } from 'components/page-header/DeprecationBanner'
9-
import { RestRepoBanner } from 'components/page-header/RestRepoBanner'
9+
import { RestBanner } from 'components/page-header/RestBanner'
1010
import { useMainContext } from 'components/context/MainContext'
1111
import { useTranslation } from 'components/hooks/useTranslation'
1212
import { useRouter } from 'next/router'
@@ -89,7 +89,7 @@ export const DefaultLayout = (props: Props) => {
8989
<Header />
9090
<main id="main-content">
9191
<DeprecationBanner />
92-
<RestRepoBanner />
92+
<RestBanner />
9393

9494
{props.children}
9595
</main>

components/Search.module.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,17 @@
5555
.versionSearchContainer {
5656
overflow: hidden;
5757
}
58+
59+
// The value in the /cb-XXXXX prefix on the URL isn't important. It just
60+
// needs to be unique so the asset can be cached in the CDN beyond
61+
// every prod deployment.
62+
// Just remember to change it if you change the image.
63+
.searchIconBackground24 {
64+
background: var(--color-canvas-default)
65+
url("/assets/cb-303/images/octicons/search-24.svg") no-repeat 12px;
66+
}
67+
68+
.searchIconBackground16 {
69+
background: var(--color-canvas-default)
70+
url("/assets/cb-262/images/octicons/search-16.svg") no-repeat 6px;
71+
}

components/Search.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ export function Search({
224224
ref={inputRef}
225225
className={cx(
226226
styles.searchInput,
227+
iconSize === 24 && styles.searchIconBackground24,
227228
iconSize === 24 && 'form-control px-6 f4',
229+
iconSize === 16 && styles.searchIconBackground16,
228230
iconSize === 16 && 'form-control px-5 f4',
229231
variant === 'compact' && 'py-2',
230232
variant === 'expanded' && 'py-3',
@@ -233,11 +235,6 @@ export function Search({
233235
isHeaderSearch && query && styles.searchInputExpanded,
234236
isHeaderSearch && query && 'position-absolute top-0 right-0'
235237
)}
236-
style={{
237-
background: `var(--color-canvas-default) url("/assets/images/octicons/search-${iconSize}.svg") no-repeat ${
238-
iconSize === 24 ? '12px' : '6px'
239-
}`,
240-
}}
241238
type="search"
242239
placeholder={t`placeholder`}
243240
autoComplete="off"

components/article/ArticlePage.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ export const ArticlePage = () => {
107107
// In the future there might be more.
108108
// Hopefully, we can some day delete all of this and no longer
109109
// be dependent on the URL hash to do the redirect.
110-
if (hash && pathname.endsWith('/rest/reference/repos')) {
110+
if (
111+
hash &&
112+
(pathname.endsWith('/rest/reference/repos') ||
113+
pathname.endsWith('/rest/reference/enterprise-admin'))
114+
) {
111115
setLoadClientsideRedirectExceptions(true)
112116
}
113117
}, [])

components/page-header/RestBanner.tsx

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import React from 'react'
2+
import { Flash } from '@primer/components'
3+
import { useRouter } from 'next/router'
4+
import { Link } from 'components/Link'
5+
6+
const restRepoDisplayPages = [
7+
'/rest/reference/branches',
8+
'/rest/reference/collaborators',
9+
'/rest/reference/commits',
10+
'/rest/reference/deployments',
11+
'/rest/reference/pages',
12+
'/rest/reference/releases',
13+
'/rest/reference/repos',
14+
'/rest/reference/metrics',
15+
'/rest/reference/webhooks',
16+
]
17+
const restEnterpriseDisplayPages = ['/rest/reference/enterprise-admin']
18+
const restRepoCategoryExceptionsTitles = {
19+
branches: 'Branches',
20+
collaborators: 'Collaborators',
21+
commits: 'Commits',
22+
deployments: 'Deployments',
23+
pages: 'GitHub Pages',
24+
releases: 'Releases',
25+
metrics: 'Metrics',
26+
webhooks: 'Webhooks',
27+
}
28+
29+
export const RestBanner = () => {
30+
const router = useRouter()
31+
const restPage = (router.query.restPage as string[]) || []
32+
const asPathRoot = `/${router.query.productId}/${restPage.join('/')}`
33+
if (
34+
!restRepoDisplayPages.includes(asPathRoot) &&
35+
!restEnterpriseDisplayPages.includes(asPathRoot)
36+
) {
37+
return null
38+
}
39+
40+
let noticeString
41+
42+
if (restRepoDisplayPages.includes(asPathRoot)) {
43+
const pages = Object.keys(restRepoCategoryExceptionsTitles) as Array<
44+
keyof typeof restRepoCategoryExceptionsTitles
45+
>
46+
const newRestPagesText = pages.map((page, i) => [
47+
<React.Fragment key={page}>
48+
<Link href={`/${router.locale}/rest/reference/${page}`}>
49+
{restRepoCategoryExceptionsTitles[page]}
50+
</Link>
51+
{i < pages.length - 1 && ', '}
52+
</React.Fragment>,
53+
])
54+
55+
noticeString = (
56+
<React.Fragment>
57+
If you can't find what you're looking for, you might try the new {newRestPagesText} REST API
58+
pages.
59+
</React.Fragment>
60+
)
61+
} else if (restEnterpriseDisplayPages.includes(asPathRoot)) {
62+
noticeString = (
63+
<React.Fragment>
64+
If you can't find what you're looking for, you might try the{' '}
65+
<Link href={`/${router.locale}/rest/reference/actions`}>Actions</Link> REST API page.
66+
</React.Fragment>
67+
)
68+
}
69+
70+
return (
71+
<div data-testid="rest-api-repos-banner" className="container-xl mt-3 mx-auto p-responsive">
72+
<Flash variant="warning">
73+
<p>
74+
<b className="text-bold">
75+
<span>We've recently moved some of the REST API documentation. {noticeString}</span>
76+
</b>{' '}
77+
</p>
78+
</Flash>
79+
</div>
80+
)
81+
}

0 commit comments

Comments
 (0)