Skip to content

Commit

Permalink
Merge pull request #38 from OpenDRR/github-token-check
Browse files Browse the repository at this point in the history
Added check to see if GitHub token is valid.
  • Loading branch information
drotheram authored Sep 3, 2020
2 parents 1a72d01 + 6bb7308 commit f086283
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions python/add_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ POSTGRES_PASS=$2
POSTGRES_PORT=$3
DB_NAME=$4

#get github token
GITHUB_TOKEN=`grep -o 'github_token = *.*' config.ini | cut -f2- -d=`

status_code=$(curl --write-out %{http_code} --silent --output /dev/null -H "Authorization: token ${GITHUB_TOKEN}" \
-O \
-L https://api.github.com/repos/OpenDRR/openquake-models/contents/deterministic/outputs)

if [[ "$status_code" -ne 200 ]] ; then
echo "GitHub token is not valid! Exiting!"
exit 0
fi

# make sure PostGIS is ready to accept connections
until pg_isready -h db-opendrr -p 5432 -U ${POSTGRES_USER}
do
echo "Waiting for postgres..."
sleep 2;
done

#get github token
GITHUB_TOKEN=`grep -o 'github_token = *.*' config.ini | cut -f2- -d=`

#get list of earthquake scenarios
curl -H "Authorization: token ${GITHUB_TOKEN}" \
-O \
Expand Down

0 comments on commit f086283

Please sign in to comment.