Skip to content

Instantly share code, notes, and snippets.

@xeraa
Last active May 16, 2017 12:46
Show Gist options
  • Save xeraa/89f5e34a869816078af96918b89385e0 to your computer and use it in GitHub Desktop.
Save xeraa/89f5e34a869816078af96918b89385e0 to your computer and use it in GitHub Desktop.
Export GitHub issues to Elasticsearch
#!/bin/bash
response=200
i=1
while [[ response -eq 200 ]]
do
curl -u '<username>:<token>' "https://api.github.com/repos/<account>/<repository>/issues?filter=all&state=all&per_page=100&page=${i}" > issues${i}.json
response=$(curl --write-out %{http_code} --silent --output /dev/null -u '<username>:<token>' "https://api.github.com/repos/<account>/<repository>/issues/$((i*100))")
((i++))
done
cat issues*.json | jq -c '.[] | {"index": {"_index": "<index>", "_type": "<type>", "_id": .id}}, .' | curl -XPOST https://<elasticsearch_server>/_bulk --user '<username>:<password>' --data-binary @-
@xeraa
Copy link
Author

xeraa commented Apr 20, 2017

Replace everything between <...> with the actual value and you are good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment