Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Netlify branch deploys should only deploy default locale "en" #7788

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ const isDev = process.env.NODE_ENV === 'development';
const isDeployPreview =
!!process.env.NETLIFY && process.env.CONTEXT === 'deploy-preview';

// Netlify branch deploy like "docusaurus-v2"
const isBranchDeploy =
!!process.env.NETLIFY && process.env.CONTEXT === 'branch-deploy';

// Used to debug production build issues faster
const isBuildFast = !!process.env.BUILD_FAST;

Expand Down Expand Up @@ -82,15 +86,16 @@ const config = {
],
i18n: {
defaultLocale: 'en',
// eslint-disable-next-line no-nested-ternary
locales: isDeployPreview
? // Deploy preview: keep it fast!
['en']
: isI18nStaging
? // Staging locales: https://docusaurus-i18n-staging.netlify.app/
['en', 'ja']
: // Production locales
['en', 'fr', 'pt-BR', 'ko', 'zh-CN'],

locales:
isDeployPreview || isBranchDeploy
? // Deploy preview and branch deploys: keep them fast!
['en']
: isI18nStaging
? // Staging locales: https://docusaurus-i18n-staging.netlify.app/
['en', 'ja']
: // Production locales
['en', 'fr', 'pt-BR', 'ko', 'zh-CN'],
},
webpack: {
jsLoader: (isServer) => ({
Expand Down Expand Up @@ -299,11 +304,15 @@ const config = {
remarkPlugins: [math, [npm2yarn, {sync: true}]],
rehypePlugins: [],
disableVersioning: isVersioningDisabled,
lastVersion: isDev || isDeployPreview ? 'current' : undefined,
lastVersion:
isDev || isDeployPreview || isBranchDeploy ? 'current' : undefined,
onlyIncludeVersions: (() => {
if (isBuildFast) {
return ['current'];
} else if (!isVersioningDisabled && (isDev || isDeployPreview)) {
} else if (
!isVersioningDisabled &&
(isDev || isDeployPreview || isBranchDeploy)
) {
return ['current', ...versions.slice(0, 2)];
}
return undefined;
Expand Down Expand Up @@ -341,7 +350,7 @@ const config = {
'./_dogfooding/dogfooding.css',
],
},
gtag: !isDeployPreview
gtag: !(isDeployPreview || isBranchDeploy)
? {
trackingID: 'UA-141789564-1',
}
Expand Down
2 changes: 1 addition & 1 deletion website/netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
command = "yarn --cwd .. build:packages && yarn netlify:build:production"

[context.branch-deploy]
command = "yarn --cwd .. build:packages && yarn netlify:build:production"
command = "yarn --cwd .. build:packages && yarn netlify:build:branchDeploy"

[context.deploy-preview]
command = "yarn --cwd .. build:packages && yarn netlify:build:deployPreview"
Expand Down
3 changes: 2 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"build:blogOnly": "cross-env yarn build --config=docusaurus.config-blog-only.js",
"build:fast": "cross-env BUILD_FAST=true yarn build --locale en",
"netlify:build:production": "yarn docusaurus write-translations && yarn netlify:crowdin:delay && yarn netlify:crowdin:uploadSources && yarn netlify:crowdin:downloadTranslations && yarn build && yarn test:css-order",
"netlify:build:deployPreview": "yarn docusaurus write-translations --locale fr --messagePrefix '(fr) ' && yarn build && yarn test:css-order",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed because we used to deploy "fr" in deploy previews, but not anymore

"netlify:build:branchDeploy": "yarn build && yarn test:css-order",
"netlify:build:deployPreview": "yarn build && yarn test:css-order",
"netlify:crowdin:delay": "node delayCrowdin.mjs",
"netlify:crowdin:wait": "node waitForCrowdin.mjs",
"netlify:crowdin:downloadTranslations": "yarn netlify:crowdin:wait && yarn --cwd .. crowdin:download:website",
Expand Down