You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This site's search functionality is powered by [Algolia](https://www.algolia.com), a third-party service.
4
18
@@ -10,65 +24,75 @@ To see all existing search-related issues and pull requests, visit [github.com/g
10
24
11
25
---
12
26
13
-
## How it Works
27
+
## How it works
14
28
15
29
The search data is synced automatically using a [GitHub Actions workflow](.github/workflows/sync-algolia-search-indices.yml) that is triggered by pushes to the `main` branch. This process generates structured data for all pages on the site, compares that data to what's currently on Algolia, then adds, updates, or removes indices based on the diff of the local and remote data, being careful not to create duplicate records and avoiding any unnecessary (and costly) indexing operations.
16
30
17
-
The Actions workflow usually takes about five minutes, and the progress can be viewed (by GitHub employees) in the [Actions tab](https://github.com/github/docs/actions?query=workflow%3AAlgolia) of the repo.
18
-
19
-
## Development
31
+
The Actions workflow progress can be viewed (by GitHub employees) in the [Actions tab](https://github.com/github/docs/actions?query=workflow%3AAlgolia) of the repo.
20
32
21
-
In cases where a publicity event like GitHub Satellite or GitHub Universe demands a very tight shipping window, it is also possible to manually sync the indices with Algolia's servers from your local checkout of the repo, before your feature branch is merged to main. Manually syncing the indices can also be useful to test an unreleased GitHub Enterprise version or a translated language (Portuguese, Chinese, etc) that is not yet in production.
33
+
## Manual sync from a checkout
22
34
23
-
To sync the indices from your development environment:
35
+
It is also possible to manually sync the indices to Algolia from your local checkout of the repo, before your branch is merged to `main`.
24
36
25
-
1. Make sure the two required environment variables `ALGOLIA_APPLICATION_ID` and `ALGOLIA_API_KEY` are set in your `.env` file. These can be retrieved from the [Algolia site](https://www.algolia.com/apps/ZI5KPY1HBE/api-keys/all).
26
-
2. Run `npm run sync-search-dry-run`. This takes a while to complete. It will prepare, test, and validate all the indices without actually uploading anything to Algolia's servers.
27
-
3. Run `npm run sync-search` to prepare the indices again and upload them to the Algolia servers.
37
+
**Prerequisite:** Make sure the environment variables `ALGOLIA_APPLICATION_ID` and `ALGOLIA_API_KEY` are set in your `.env` file. You can find these values on [Algolia](https://www.algolia.com/apps/ZI5KPY1HBE/api-keys/all).
28
38
29
-
## Build indices for a specific language and/or version
39
+
###Build without sync (dry run)
30
40
31
-
You can optionally build indices for a given language and/or a version. This is much faster than building all the indices.
32
-
33
-
You can build them as a dry run, which creates the index locally but does not upload them to Algolia. For example:
41
+
To build all the indices without uploading them to Algolia's servers (this takes about an hour):
34
42
```
35
-
VERSION='free-pro-team@latest' LANGUAGE='en' npm run sync-search-dry-run
43
+
npm run sync-search-dry-run
36
44
```
37
-
Or you can build and load them to Algolia to make them live:
45
+
To build indices for a specific language and/or version (this is much faster):
38
46
```
39
-
VERSION='free-pro-team@latest' LANGUAGE='en' npm run sync-search
47
+
VERSION=<PLAN@RELEASE> LANGUAGE=<TWO-LETTER CODE> npm run sync-search-dry-run
40
48
```
41
-
The `VERSION` environment variable must be a currently supported version in `<PLAN@RELEASE>` format. The `LANGUAGE`environment variable must be a currently supported two-letter language code.
49
+
You can set `VERSION` and `LANGUAGE`individually, too.
42
50
43
-
### Label-triggered workflow
51
+
Substitute a currently supported version for `<PLAN@RELEASE>` and a currently supported two-letter language code for `<TWO-LETTER-CODE>`.
44
52
45
-
For our daily shipping needs, the indices are synced to Algolia only after a PR is shipped to the default branch, which means the search data isn't available for up to an hour after the content goes live.
53
+
### Build and sync
46
54
47
-
But for GHES releases, we have additional needs. We want:
55
+
To build all the indices and sync them to Algolia (this also takes about an hour):
56
+
```
57
+
npm run sync-search
58
+
```
59
+
To build indices for a specific language and/or version and sync them to Algolia:
60
+
```
61
+
VERSION=<PLAN@RELEASE LANGUAGE=<TWO-LETTER CODE> npm run sync-search
62
+
```
63
+
You can set `VERSION` and `LANGUAGE` individually, too.
48
64
49
-
1) The search results to be live immediately upon releasing the new content.
50
-
2) The search results to be viewable on the staging app for the GHES release megabranch.
65
+
Substitute a currently supported version for `<PLAN@RELEASE>` and a currently supported two-letter language code for `<TWO-LETTER-CODE>`.
51
66
52
-
Manually running `npm run sync` locally before shipping the megabranch can address #1, but it's cumbersome and hard to get the timing right. And it does not address #2.
67
+
## Label-triggered workflow
53
68
54
-
Now, docs team members can use an Actions workflow on GHES megabranch PRs by applying a label in this format:
69
+
Docs team members can use an Actions workflow on GHES release PRs by applying a label in this format:
55
70
```
56
71
sync-english-index-for-<PLAN@RELEASE>
57
72
```
58
-
This label will run a workflow on every push to**build and upload ONLY** the English index for the specified version. This means:
73
+
This label will run a workflow on every push that**builds and uploads ONLY** the English index for the specified version. This means:
59
74
60
-
* The GHES content will be searchable at the same time the megabranch is shipped, with no delay.
75
+
* The GHES content will be searchable at the same time the release PR is shipped, with no delay.
61
76
* The GHES content will be searchable on staging throughout content creation.
62
-
* No manual steps (unless anyone wants to do a dry-run test as described in the previous section).
77
+
* No manual steps (unless you want to do a [dry run test](#build-without-sync-dry-run)).
78
+
79
+
Why do we need this? For our daily shipping needs, it's tolerable that search updates aren't available for up to an hour after the content goes live. But GHES releases are more time-sensitive, and writers have a greater need to preview search data on staging.
63
80
64
81
## Files
65
82
66
-
-[.github/workflows/sync-algolia-search-indices.yml](.github/workflows/sync-algolia-search-indices.yml) - the GitHub Actions workflow file that updates search indices whenever the main branch is updated.
67
-
-[javascripts/search.js](javascripts/search.js) - the browser-side code that enables search using Algolia's [InstantSearch.js](https://github.com/algolia/instantsearch.js/) library.
68
-
-[lib/algolia/client.js](lib/algolia/client.js) - a thin wrapper around the [algoliasearch](https://ghub.io/algoliasearch) Node.js module for interacting with the Algolia API.
69
-
-[lib/algolia/search-index.js](lib/algolia/search-index.js) - a class for generating structured search data from repository content and syncing it with the remote Algolia service. This class has built-in validation to ensure that all records are valid before they're uploaded. This class also takes care of removing deprecated records, and compares existing remote records with the latest local records to avoid uploading records that haven't changed.
70
-
-[script/sync-algolia-search-indices.js](script/sync-algolia-search-indices.js) - the script used by the Actions workflow to update search indices on our Algolia account. This can also be [run in the development environment](#development).
-[`.github/workflows/sync-algolia-search-indices.yml`](.github/workflows/sync-algolia-search-indices.yml) - Builds and syncs search indices whenever the `main` branch is pushed to (that is, on production deploys).
86
+
-[`.github/workflows/dry-run-sync-algolia-search-indices.yml`](.github/workflows/dry-run-sync-algolia-search-indices.yml) - This workflow can be run manually (via `workflow_dispatch`) to do a dry run build of all the indices. Useful for confirming that the indices can build without erroring out.
87
+
-[`.github/workflows/sync-single-english-algolia-index.yml`](.github/workflows/sync-single-english-algolia-index.yml) - This workflow is run when a label in the right format is applied to a PR. See "[Label-triggered workflow](#label-triggered-workflow)" for details.
88
+
89
+
### Code files
90
+
91
+
-[javascripts/search.js](javascripts/search.js) - The browser-side code that enables search using Algolia's [InstantSearch.js](https://github.com/algolia/instantsearch.js/) library.
92
+
-[lib/algolia/client.js](lib/algolia/client.js) - A thin wrapper around the [algoliasearch](https://ghub.io/algoliasearch) Node.js module for interacting with the Algolia API.
93
+
-[lib/algolia/search-index.js](lib/algolia/search-index.js) - A class for generating structured search data from repository content and syncing it with the remote Algolia service. This class has built-in validation to ensure that all records are valid before they're uploaded. This class also takes care of removing deprecated records, and compares existing remote records with the latest local records to avoid uploading records that haven't changed.
94
+
-[script/sync-algolia-search-indices.js](script/sync-algolia-search-indices.js) - The script used by the Actions workflow to update search indices on our Algolia account. This can also be [run in the development environment](#development).
0 commit comments