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,30 +24,77 @@ 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
+
## Production deploys
28
+
29
+
A [GitHub Actions workflow](.github/workflows/sync-algolia-search-indices.yml) triggered by pushes to the `main` branch syncs the search data to Algolia. 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.
30
+
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.
32
+
33
+
Because the workflow runs after a branch is merged to `main`, there is a slight delay for search data updates to appear on the site.
34
+
35
+
## Manual sync from a checkout
36
+
37
+
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`.
38
+
39
+
**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).
40
+
41
+
### Build without sync (dry run)
42
+
43
+
To build all the indices without uploading them to Algolia's servers (this takes about an hour):
44
+
```
45
+
npm run sync-search-dry-run
46
+
```
47
+
To build indices for a specific language and/or version (this is much faster):
48
+
```
49
+
VERSION=<PLAN@RELEASE> LANGUAGE=<TWO-LETTER CODE> npm run sync-search-dry-run
50
+
```
51
+
You can set `VERSION` and `LANGUAGE` individually, too.
52
+
53
+
Substitute a currently supported version for `<PLAN@RELEASE>` and a currently supported two-letter language code for `<TWO-LETTER-CODE>`.
14
54
15
-
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.
55
+
### Build and sync
16
56
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.
57
+
To build all the indices and sync them to Algolia (this also takes about an hour):
58
+
```
59
+
npm run sync-search
60
+
```
61
+
To build indices for a specific language and/or version and sync them to Algolia:
62
+
```
63
+
VERSION=<PLAN@RELEASE LANGUAGE=<TWO-LETTER CODE> npm run sync-search
64
+
```
65
+
You can set `VERSION` and `LANGUAGE` individually, too.
18
66
19
-
## Development
67
+
Substitute a currently supported version for `<PLAN@RELEASE>` and a currently supported two-letter language code for `<TWO-LETTER-CODE>`.
20
68
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.
69
+
## Label-triggered Actions workflow
22
70
23
-
To sync the indices from your development environment:
71
+
Docs team members can use an Actions workflow on GHES release PRs by applying a label in this format:
72
+
```
73
+
sync-english-index-for-<PLAN@RELEASE>
74
+
```
75
+
This label will run a workflow on every push that **builds and uploads ONLY** the English index for the specified version. This means:
76
+
77
+
* The GHES content will be searchable at the same time the release PR is shipped, with no delay.
78
+
* The GHES content will be searchable on staging throughout content creation.
79
+
* No manual steps (unless you want to do a [dry run test](#build-without-sync-dry-run)).
24
80
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.
81
+
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.
28
82
29
83
## Files
30
84
31
-
-[.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.
32
-
-[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.
33
-
-[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.
34
-
-[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.
35
-
-[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).
88
+
-[`.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.
89
+
-[`.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 Actions workflow](#label-triggered-actions-workflow)" for details.
90
+
91
+
### Code files
92
+
93
+
-[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.
94
+
-[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.
95
+
-[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.
96
+
-[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