Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSarah German <sgerman@gitlab.com>2022-12-15 11:51:38 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2022-12-15 11:51:38 +0300
commit1cd3b6d14bd66d5aa2aab28772f361987df2199c (patch)
tree62d3d8a5861a7de026804c624dec648aea7c8914
parent6f3b4360ff6bb85574dd0d25eb3bd873901d9f43 (diff)
Conditionally run Algolia search in review apps
-rw-r--r--.gitlab/ci/build-and-deploy.gitlab-ci.yml4
-rw-r--r--content/frontend/default/environment.js4
-rw-r--r--content/frontend/search/search.js33
3 files changed, 22 insertions, 19 deletions
diff --git a/.gitlab/ci/build-and-deploy.gitlab-ci.yml b/.gitlab/ci/build-and-deploy.gitlab-ci.yml
index ce41b369..a2a90fb4 100644
--- a/.gitlab/ci/build-and-deploy.gitlab-ci.yml
+++ b/.gitlab/ci/build-and-deploy.gitlab-ci.yml
@@ -77,6 +77,10 @@ compile_dev:
- .build_base
variables:
ALGOLIA_SEARCH: 'false'
+ rules:
+ - if: $CI_COMMIT_REF_NAME =~ /algolia/
+ variables:
+ ALGOLIA_SEARCH: 'true'
script:
- !reference [".compile-and-minify-scripts", "script"]
- !reference [".gzip-scripts", "script"]
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 (