Skip to content

Commit

Permalink
fixup algolia
Browse files Browse the repository at this point in the history
  • Loading branch information
jkralik committed Mar 12, 2024
1 parent e14c97f commit d03a385
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
25 changes: 8 additions & 17 deletions .github/workflows/algolia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,27 @@ jobs:
uses: actions/checkout@v2

- name: Install npm dependencies
run: npm install --legacy-peer-deps hugo-algolia
run: npm install -g --legacy-peer-deps hugo-algolia

- name: Check if hugo-algolia is installed
run: command -v hugo-algolia

- name: Find hugo-algolia
run: find / -name "hugo-algolia" -type f 2>/dev/null
run: hugo-algolia --version

- name: Generate algolia.json
run: hugo-algolia --config config/_default/config.yaml

- name: Copy algolia.json to tools/adjust-algolia-output
run: cp algolia.json tools/adjust-algolia-output/

- name: Build Go binary
run: go build
run: go build -o adjust-algolia-output tools/adjust-algolia-output/main.go

- name: Adjust algolia.json using binary
run: ./adjust-algolia-output < ./algolia.json | jq > adjusted-algolia.json

- name: Move adjusted algolia.json to scripts folder
run: mv adjusted-algolia.json scripts/
run: ./adjust-algolia-output < ./public/algolia.json | jq > scripts/algolia.json

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install node dependencies
run: npm install

- name: Push to Algolia
run: node push-to-algolia.json
run: |
cd scripts
npm install
APPLICATION_ID=${{ secrets.ALGOLIA_API_KEY }} API_KEY=${{ secrets.ALGOLIA_API_KEY }} node push-to-algolia.json scripts/algolia.json
4 changes: 2 additions & 2 deletions scripts/push-to-algolia.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ const algoliasearch = require('algoliasearch');
const fs = require('fs');

// Initialize Algolia client
const client = algoliasearch('42D6VHXINQ', '16bcaaf3bbf281af8c223e692457336c');
const client = algoliasearch(process.env.APPLICATION_ID, process.env.API_KEY);
const index = client.initIndex('doc');

// Read JSON file
const jsonData = fs.readFileSync('algolia_final.json', 'utf8');
const jsonData = fs.readFileSync(process.argv[1], 'utf8');

// Parse JSON data
const records = JSON.parse(jsonData);
Expand Down

0 comments on commit d03a385

Please sign in to comment.