Commit 1d3283d8 authored by Cole Bemis's avatar Cole Bemis

build: Add sync-algolia script

parent 894dcfd6
......@@ -9,6 +9,8 @@ before_script:
- npm prune
script:
- npm start
after_success:
- npx babel-node ./bin/sync-algolia.js
deploy:
provider: script
skip_cleanup: true
......
/* eslint-disable import/no-extraneous-dependencies */
import algolia from 'algoliasearch';
import icons from '../dist/icons.json';
import tags from '../src/tags.json';
const ALGOLIA_APP_ID = '5EEOG744D0';
if (
process.env.TRAVIS_PULL_REQUEST === 'false' &&
process.env.TRAVIS_BRANCH === 'master'
) {
syncAlgolia();
}
function syncAlgolia() {
const client = algolia(ALGOLIA_APP_ID, process.env.ALGOLIA_ADMIN_KEY);
const index = client.initIndex('icons');
const records = Object.keys(icons).map(name => ({
name,
tags: tags[name] || [],
}));
index.clearIndex((err, content) => {
if (err) throw err;
console.log(content); // eslint-disable-line no-console
});
index.addObjects(records, (err, content) => {
if (err) throw err;
console.log(content); // eslint-disable-line no-console
});
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment