Skip to content
This repository was archived by the owner on Feb 9, 2022. It is now read-only.

feat: trigger a crawl when a PR is merged #2059

Merged
merged 1 commit into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,25 @@ jobs:
- run: sudo apt-get update
- run: sudo apt-get install jq
- run: ./.circleci/valid_edited_configs.sh
deploy:
docker:
- image: circleci/ruby:2.4.1
steps:
- checkout
- run: git remote add original_repo [email protected]:algolia/docsearch-configs.git
- run: git fetch original_repo
- run: sudo apt-get update
- run: sudo apt-get update
- run: sudo apt-get install jq
- run: ./.circleci/trigger_crawl.sh
workflows:
version: 2
one_and_two:
jobs:
- valid_edited_configs
- deploy:
filters:
branches:
only: master
requires:
- valid_edited_configs
19 changes: 19 additions & 0 deletions .circleci/trigger_crawl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Exit script if you try to use an uninitialized variable.
set -o nounset

# Exit script if a statement returns a non-true return value.
set -o errexit

# Use the error status of the first failure, rather than that of the last item in a pipeline.
set -o pipefail

FILES=$(git diff HEAD original_repo/master --name-only ./configs)

for f in $FILES
do
echo "Triggering a crawl for $f configuration"
jq -e '.nb_hits=0 | .' < "$f" | curl -d @- -H 'Content-Type: application/json' -X POST ${CRAWL_ENDPOINT} -u ${CRAWL_USERNAME}:${CRAWL_PWD}

done