Last active
May 16, 2017 12:46
-
-
Save xeraa/89f5e34a869816078af96918b89385e0 to your computer and use it in GitHub Desktop.
Export GitHub issues to Elasticsearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 @- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace everything between
<...>
with the actual value and you are good to go.