diff --git a/.eslintrc.js b/.eslintrc.js index 34d7f62ee1..b18ceca086 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,7 +5,7 @@ module.exports = { es2020: true, node: true }, - parser: 'babel-eslint', + parser: '@babel/eslint-parser', extends: [ 'eslint:recommended', 'standard' diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b07cb1e945..750dc0410c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,6 +5,8 @@ # Engineering *.js @github/docs-engineering +*.ts @github/docs-engineering +*.tsx @github/docs-engineering /.github/ @github/docs-engineering /script/ @github/docs-engineering /includes/ @github/docs-engineering diff --git a/.github/allowed-actions.js b/.github/allowed-actions.js index 71a5037dd7..8824ee507f 100644 --- a/.github/allowed-actions.js +++ b/.github/allowed-actions.js @@ -34,7 +34,6 @@ module.exports = [ "peter-evans/create-pull-request@8c603dbb04b917a9fc2dd991dc54fef54b640b43", "rachmari/actions-add-new-issue-to-column@1a459ef92308ba7c9c9dc2fcdd72f232495574a9", "rachmari/labeler@832d42ec5523f3c6d46e8168de71cd54363e3e2e", - "rachmari/puppeteer-container@6d56d6e132a3df76cf60bc290a4282f7fbaed05e", "repo-sync/github-sync@3832fe8e2be32372e1b3970bbae8e7079edeec88", "repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d", "someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd", diff --git a/.github/workflows/add-review-template.yml b/.github/workflows/add-review-template.yml index 55216a0ec1..ddff524a75 100644 --- a/.github/workflows/add-review-template.yml +++ b/.github/workflows/add-review-template.yml @@ -13,7 +13,7 @@ jobs: comment-that-approved: name: Add review template runs-on: ubuntu-latest - if: github.event.label.name == 'docs-content-ready-for-review' && github.repository == 'github/docs-internal' + if: github.event.label.name == 'add-review-template' && github.repository == 'github/docs-internal' steps: - name: check out repo content diff --git a/.github/workflows/browser-test.yml b/.github/workflows/browser-test.yml index 79dff097b1..a8eef4dca9 100644 --- a/.github/workflows/browser-test.yml +++ b/.github/workflows/browser-test.yml @@ -23,16 +23,23 @@ jobs: - name: Setup Node uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e with: - node-version: 14.x + node-version: 16.x - - name: Install - uses: rachmari/puppeteer-container@6d56d6e132a3df76cf60bc290a4282f7fbaed05e - timeout-minutes: 5 - with: - args: npm ci + - name: Get npm cache directory + id: npm-cache + run: | + echo "::set-output name=dir::$(npm config get cache)" - - name: Test - timeout-minutes: 10 - uses: rachmari/puppeteer-container@6d56d6e132a3df76cf60bc290a4282f7fbaed05e + - name: Cache node modules + uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a with: - args: npm run browser-test + path: ${{ steps.npm-cache.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies + run: npm ci --include=optional + + - name: Run brower-test + run: npm run browser-test diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 2949d26179..3d653683d0 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -23,4 +23,4 @@ jobs: - name: Check out repo uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f - name: Build the container - run: docker build . + run: docker build --target production . diff --git a/.github/workflows/dry-run-sync-algolia-search-indices.yml b/.github/workflows/dry-run-sync-algolia-search-indices.yml index 578a93b05e..77aa9e9550 100644 --- a/.github/workflows/dry-run-sync-algolia-search-indices.yml +++ b/.github/workflows/dry-run-sync-algolia-search-indices.yml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f - uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e with: - node-version: 14.x + node-version: 16.x - name: cache node modules uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a with: diff --git a/.github/workflows/js-lint.yml b/.github/workflows/js-lint.yml index 9245c1eb6c..1b4478dc64 100644 --- a/.github/workflows/js-lint.yml +++ b/.github/workflows/js-lint.yml @@ -21,7 +21,7 @@ jobs: - name: Setup node uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e with: - node-version: 14.x + node-version: 16.x - name: Get npm cache directory id: npm-cache diff --git a/.github/workflows/link-check-dotcom.yml b/.github/workflows/link-check-dotcom.yml index bb9f024ab1..02fc2873ac 100644 --- a/.github/workflows/link-check-dotcom.yml +++ b/.github/workflows/link-check-dotcom.yml @@ -23,7 +23,7 @@ jobs: - name: Setup node uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e with: - node-version: 14.x + node-version: 16.x - name: Install run: npm ci diff --git a/.github/workflows/link-check-ghae.yml b/.github/workflows/link-check-ghae.yml index 3f466eae5d..26ba95b995 100644 --- a/.github/workflows/link-check-ghae.yml +++ b/.github/workflows/link-check-ghae.yml @@ -23,7 +23,7 @@ jobs: - name: Setup node uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e with: - node-version: 14.x + node-version: 16.x - name: Install run: npm ci diff --git a/.github/workflows/link-check-ghes.yml b/.github/workflows/link-check-ghes.yml index f26b9cfbe6..7b4fb7db41 100644 --- a/.github/workflows/link-check-ghes.yml +++ b/.github/workflows/link-check-ghes.yml @@ -23,7 +23,7 @@ jobs: - name: Setup node uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e with: - node-version: 14.x + node-version: 16.x - name: Install run: npm ci diff --git a/.github/workflows/pa11y.yml b/.github/workflows/pa11y.yml index a9a254a405..60ab35978d 100644 --- a/.github/workflows/pa11y.yml +++ b/.github/workflows/pa11y.yml @@ -16,6 +16,11 @@ jobs: - name: Check out repo uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f + - name: Setup Node + uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e + with: + node-version: 16.x + - name: Get npm cache directory id: npm-cache run: | @@ -30,7 +35,7 @@ jobs: ${{ runner.os }}-node- - name: Install dependencies - run: npm ci + run: npm ci --include=optional - name: Run build scripts run: npm run build diff --git a/.github/workflows/send-crowdin-prs-to-boards.yml b/.github/workflows/send-crowdin-prs-to-boards.yml deleted file mode 100644 index 7d016122d1..0000000000 --- a/.github/workflows/send-crowdin-prs-to-boards.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Send Crowdin PRs to boards - -# **What it does**: Sends PRs opened on the crowdin branch to the ready for work column in this board: https://github.com/orgs/github/projects/1269#column-13447153 -# **Why we have it**: To make sure the first responder sees crowdin translations that need to be merged as they review the Task board. -# **Who does it impact**: Docs localization and Docs Engineering - -on: - pull_request: - types: - - opened - -jobs: - triage: - if: github.repository == 'github/docs-internal' && github.event.pull_request.head.ref == 'translations' - runs-on: ubuntu-latest - steps: - - uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9 - with: - github-token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }} - script: | - var squadBoardColumnId = 13447153; // Add to the team task board - - try { - await github.projects.createCard({ - column_id: squadBoardColumnId, - content_id: context.payload.pull_request.id, - content_type: "PullRequest" - }); - } catch (error) { - console.log(error); - } diff --git a/.github/workflows/site-policy-sync.yml b/.github/workflows/site-policy-sync.yml index 12bb02ffbf..15eaa5c14f 100644 --- a/.github/workflows/site-policy-sync.yml +++ b/.github/workflows/site-policy-sync.yml @@ -22,7 +22,9 @@ on: jobs: # This workflow contains a single job called "build" copy-file: - if: github.repository == 'github/docs-internal' + if: | + github.event.pull_request.merged == true && + github.repository == 'github/docs-internal' # The type of runner that the job will run on runs-on: ubuntu-latest diff --git a/.github/workflows/sync-algolia-search-indices.yml b/.github/workflows/sync-algolia-search-indices.yml index 24d7391d8f..ea2cc60e85 100644 --- a/.github/workflows/sync-algolia-search-indices.yml +++ b/.github/workflows/sync-algolia-search-indices.yml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f - uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e with: - node-version: 14.x + node-version: 16.x - name: cache node modules uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a with: diff --git a/.github/workflows/sync-single-english-algolia-index.yml b/.github/workflows/sync-single-english-algolia-index.yml index 790e218c4a..39e66e1abe 100644 --- a/.github/workflows/sync-single-english-algolia-index.yml +++ b/.github/workflows/sync-single-english-algolia-index.yml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f - uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e with: - node-version: 14.x + node-version: 16.x - name: cache node modules uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a with: diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index b917a2a38d..4a39a63057 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -34,7 +34,7 @@ jobs: - name: Setup node uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e with: - node-version: 14.x + node-version: 16.x - name: Get npm cache directory id: npm-cache diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 21b31785e1..5c8acfc0b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: - name: Setup node uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e with: - node-version: 14.x + node-version: 16.x - name: Get npm cache directory id: npm-cache diff --git a/.github/workflows/yml-lint.yml b/.github/workflows/yml-lint.yml index f74bf200b5..b2a4a3ce70 100644 --- a/.github/workflows/yml-lint.yml +++ b/.github/workflows/yml-lint.yml @@ -27,7 +27,7 @@ jobs: - name: Setup node uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e with: - node-version: 14.x + node-version: 16.x - name: Get npm cache directory id: npm-cache diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 0000000000..31354ec138 --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000000..7c142f8f50 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +node script/prevent-translation-commits.js diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 0000000000..c3e157d88b --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npm run prevent-pushes-to-main diff --git a/.node-version b/.node-version index 98b0fc5f44..1c2b43343f 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -14.13.0 \ No newline at end of file +16.2.0 \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bd21c52ce9..ba27238c5c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,7 +38,7 @@ Fork with [GitHub Codespaces](https://github.com/features/codespaces): ### Make your update: Make your changes to the file(s) you'd like to update. Here are some tips and tricks for [using the docs codebase](#working-in-the-githubdocs-repository). - - Are you making changes to the application code? You'll need **Node.js v14** to run the site locally. See [contributing/development.md](contributing/development.md). + - Are you making changes to the application code? You'll need **Node.js v16** to run the site locally. See [contributing/development.md](contributing/development.md). - Are you contributing to markdown? We use [GitHub Markdown](contributing/content-markup-reference.md). ### Open a pull request diff --git a/Dockerfile b/Dockerfile index 6ebd4a9adf..c360b4e2ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,25 +3,62 @@ # It uses two multi-stage builds: `install` and the main build to keep the image size down. # -------------------------------------------------------------------------------- -# INSTALL IMAGE -# A temporary image that installs production-only dependencies and builds the production-ready front-end bundles. +# BASE IMAGE +# -------------------------------------------------------------------------------- +FROM node:16.2.0-alpine as base + +RUN apk add --no-cache make g++ git -FROM node:14-alpine as install -RUN apk add --no-cache python make g++ -ENV NODE_ENV production WORKDIR /usr/src/docs + + +# --------------- +# ALL DEPS +# --------------- +FROM base as all_deps + COPY package*.json ./ + +RUN npm ci + + +# --------------- +# PROD DEPS +# --------------- +FROM all_deps as prod_deps + +RUN npm prune --production + + +# --------------- +# BUILDER +# --------------- +FROM all_deps as builder + +ENV NODE_ENV production + COPY javascripts ./javascripts COPY stylesheets ./stylesheets +COPY pages ./pages +COPY components ./components COPY lib ./lib + +# one part of the build relies on this content file to pull all-products +COPY content/index.md ./content/index.md + COPY webpack.config.js ./webpack.config.js -RUN npm ci --production +COPY next.config.js ./next.config.js +COPY tsconfig.json ./tsconfig.json + +RUN npx tsc + RUN npm run build # -------------------------------------------------------------------------------- # MAIN IMAGE +# -------------------------------------------------------------------------------- -FROM node:14-alpine +FROM node:16.2.0-alpine as production # Let's make our home WORKDIR /usr/src/docs @@ -32,11 +69,12 @@ RUN chown node:node /usr/src/docs -R # This should be our normal running user USER node -# Copy our dependencies -COPY --chown=node:node --from=install /usr/src/docs/node_modules /usr/src/docs/node_modules +# Copy just our prod dependencies +COPY --chown=node:node --from=prod_deps /usr/src/docs/node_modules /usr/src/docs/node_modules # Copy our front-end code -COPY --chown=node:node --from=install /usr/src/docs/dist /usr/src/docs/dist +COPY --chown=node:node --from=builder /usr/src/docs/dist /usr/src/docs/dist +COPY --chown=node:node --from=builder /usr/src/docs/.next /usr/src/docs/.next # We should always be running in production mode ENV NODE_ENV production diff --git a/app.json b/app.json index 75a201a8b6..14f8ba9f54 100644 --- a/app.json +++ b/app.json @@ -2,7 +2,6 @@ "name": "docs.github.com", "env": { "NODE_ENV": "production", - "NPM_CONFIG_PRODUCTION": "true", "ENABLED_LANGUAGES": "en", "WEB_CONCURRENCY": "1" }, diff --git a/assets/images/help/desktop/diff-selection.png b/assets/images/help/desktop/diff-selection.png new file mode 100644 index 0000000000..170b1d4af3 Binary files /dev/null and b/assets/images/help/desktop/diff-selection.png differ diff --git a/assets/images/help/desktop/expand-diff-view.png b/assets/images/help/desktop/expand-diff-view.png new file mode 100644 index 0000000000..4636378c73 Binary files /dev/null and b/assets/images/help/desktop/expand-diff-view.png differ diff --git a/assets/images/help/images/example-script-injection-mitigated.png b/assets/images/help/images/example-script-injection-mitigated.png new file mode 100644 index 0000000000..b3e5cdfa80 Binary files /dev/null and b/assets/images/help/images/example-script-injection-mitigated.png differ diff --git a/assets/images/help/images/example-script-injection-pr-title.png b/assets/images/help/images/example-script-injection-pr-title.png new file mode 100644 index 0000000000..9502388745 Binary files /dev/null and b/assets/images/help/images/example-script-injection-pr-title.png differ diff --git a/assets/images/help/images/example-script-injection-result.png b/assets/images/help/images/example-script-injection-result.png new file mode 100644 index 0000000000..180f4c3a14 Binary files /dev/null and b/assets/images/help/images/example-script-injection-result.png differ diff --git a/assets/images/help/package-registry/packages-diagram-with-container-registry.png b/assets/images/help/package-registry/packages-diagram-with-container-registry.png index cab75ad8c2..215afe21ea 100644 Binary files a/assets/images/help/package-registry/packages-diagram-with-container-registry.png and b/assets/images/help/package-registry/packages-diagram-with-container-registry.png differ diff --git a/assets/images/help/package-registry/packages-diagram-without-container-registry.png b/assets/images/help/package-registry/packages-diagram-without-container-registry.png index d6c38eddbf..c21985462f 100644 Binary files a/assets/images/help/package-registry/packages-diagram-without-container-registry.png and b/assets/images/help/package-registry/packages-diagram-without-container-registry.png differ diff --git a/assets/images/help/pull_requests/conversations-menu.png b/assets/images/help/pull_requests/conversations-menu.png new file mode 100644 index 0000000000..5fed02a035 Binary files /dev/null and b/assets/images/help/pull_requests/conversations-menu.png differ diff --git a/assets/images/help/repository/require-conversation-resolution.png b/assets/images/help/repository/require-conversation-resolution.png new file mode 100644 index 0000000000..bcfbe7ae27 Binary files /dev/null and b/assets/images/help/repository/require-conversation-resolution.png differ diff --git a/assets/images/help/repository/require-signed-commits.png b/assets/images/help/repository/require-signed-commits.png index 67b4ae4f42..e10b3ca9c4 100644 Binary files a/assets/images/help/repository/require-signed-commits.png and b/assets/images/help/repository/require-signed-commits.png differ diff --git a/assets/images/marketplace/publish-your-app-checklist-and-submission.png b/assets/images/marketplace/publish-your-app-checklist-and-submission.png index bee1f907d2..5b21a3d036 100644 Binary files a/assets/images/marketplace/publish-your-app-checklist-and-submission.png and b/assets/images/marketplace/publish-your-app-checklist-and-submission.png differ diff --git a/components/Contribution.tsx b/components/Contribution.tsx index e7135a6663..c0da509161 100644 --- a/components/Contribution.tsx +++ b/components/Contribution.tsx @@ -20,7 +20,11 @@ export const Contribution = () => {

{t`or`}{' '} - + {t`to_guidelines`}

diff --git a/components/DefaultLayout.tsx b/components/DefaultLayout.tsx index c9cb3f37f8..ba82925984 100644 --- a/components/DefaultLayout.tsx +++ b/components/DefaultLayout.tsx @@ -7,16 +7,43 @@ import { ScrollButton } from 'components/ScrollButton' import { SupportSection } from 'components/SupportSection' import { DeprecationBanner } from 'components/DeprecationBanner' import { useMainContext } from 'components/context/MainContext' +import { useTranslation } from './hooks/useTranslation' +import { useVersion } from './hooks/useVersion' type Props = { children?: React.ReactNode } export const DefaultLayout = (props: Props) => { - const { builtAssets, expose } = useMainContext() + const { builtAssets, expose, page, error } = useMainContext() + const { currentVersion } = useVersion() + const { t } = useTranslation('errors') return (
+ {error === '404' ? ( + {t('oops')} + ) : currentVersion !== 'homepage' && page.fullTitle ? ( + {page.fullTitle} + ) : null} +