diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2022-12-15 16:35:49 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2022-12-15 16:35:49 +0300 |
commit | dc147fbc1b909e5f054ac2bfb598188a1b91d81e (patch) | |
tree | 6dd9bcafd34ffbf1aec497e5d82ab8a2b8470e5a | |
parent | a3367d45cb505eb60b82120464b96ff652039eee (diff) | |
parent | cafb5c4c693bcfa4ed7e18bfae0e939f6169b522 (diff) |
Merge branch 'algolia-dev-pipeline-option' into 'main'
Re-implement algolia option for dev MRs
See merge request https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/3373
Merged-by: Achilleas Pipinellis <axil@gitlab.com>
Co-authored-by: Marcel Amirault <mamirault@gitlab.com>
-rw-r--r-- | .gitlab/ci/rules.gitlab-ci.yml | 3 | ||||
-rw-r--r-- | content/frontend/default/environment.js | 4 | ||||
-rw-r--r-- | content/frontend/search/search.js | 33 |
3 files changed, 21 insertions, 19 deletions
diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 535a8ca2..ef954738 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -129,6 +129,9 @@ default: .rules_dev: rules: + - if: $CI_MERGE_REQUEST_ID && $CI_COMMIT_REF_NAME =~ /algolia/ + variables: + ALGOLIA_SEARCH: 'true' - if: '$CI_MERGE_REQUEST_ID' - if: '$CI_COMMIT_BRANCH =~ /docs-preview/' # TODO: Remove once no projects create such branch - if: '$CI_PIPELINE_SOURCE == "schedule" && $CHORES_PIPELINE == "true"' diff --git a/content/frontend/default/environment.js b/content/frontend/default/environment.js index 8d530ded..e09a83c4 100644 --- a/content/frontend/default/environment.js +++ b/content/frontend/default/environment.js @@ -28,3 +28,7 @@ export function isGitLabHosted() { export function isArchivesSite() { return window.location.host === GlHosts.find((x) => x.environment === 'archives').host; } + +export function isProduction() { + return window.location.host === GlHosts.find((x) => x.environment === 'production').host; +} diff --git a/content/frontend/search/search.js b/content/frontend/search/search.js index b0132354..ea98f6e3 100644 --- a/content/frontend/search/search.js +++ b/content/frontend/search/search.js @@ -1,30 +1,25 @@ +import { isProduction } from '../default/environment'; + /** - * Functions used by both DocSearch and InstantSearch. + * Loads Algolia connection info. + * + * For production, we use the "gitlab" index. + * All other environments use the "gitlab_testing" index. + * Both indexes use the same credentials to connect. + * + * @see https://www.algolia.com/apps/3PNCFOU757/indices */ - -export const algoliaAccounts = { - production: { +export const getAlgoliaCredentials = () => { + return { apiKey: 'eef4ee4af5ab6b0d76d1a2f9fc4fab58', appId: '3PNCFOU757', - index: 'gitlab', - }, - testing: { - apiKey: 'eef4ee4af5ab6b0d76d1a2f9fc4fab58', - appId: '3PNCFOU757', - index: 'gitlab_testing', - }, + index: isProduction() ? 'gitlab' : 'gitlab_testing', + }; }; /** - * Loads Algolia connection info for a given Crawler. - * - * Set the crawler default to 'testing' in order to use - * the gitlab_testing index. (Don't forget to change it back!) + * Returns the site version from the docsearch:version metatag. */ -export const getAlgoliaCredentials = (crawler = 'production') => { - return algoliaAccounts[crawler]; -}; - export const getDocsVersion = () => { let docsVersion = 'main'; if ( |