Skip to content

Commit 18aebe6

Browse files
committed
CircleCI: Authenticate requests & dump GitHub ratelimit headers on failure
1 parent 0c7e2f8 commit 18aebe6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

.circleci/config.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ jobs:
9393
fetched=false
9494
for i in $(seq 1 5); do
9595
echo ""
96-
res=$(curl -fsS https://api.github.com/repos/arangodb/docs-hugo/contents/.circleci?ref=$CIRCLE_SHA1) || curlStatus=$?
96+
headers=$(mktemp)
97+
res=$(curl -sS -D "$headers" -H "Authorization: Bearer $CIRCLECI_GITHUB_READONLY" https://api.github.com/repos/arangodb/docs-hugo/contents/.circleci?ref=$CIRCLE_SHA1) || curlStatus=$?
98+
headers_content=$(cat "$headers")
99+
rm "$headers"
97100
if [[ -z "${curlStatus:-}" ]]; then
98101
urls=$(echo "$res" | jq ".[].download_url") || jqStatus=$?
99102
if [[ -z "${jqStatus:-}" ]]; then
@@ -103,7 +106,8 @@ jobs:
103106
echo "jq failed with $jqStatus, input:"
104107
echo "$res"
105108
else
106-
echo "curl failed with $curlStatus"
109+
echo "curl failed with $curlStatus, rate limit?"
110+
echo "$headers_content" | grep -i "ratelimit\|retry-after"
107111
fi
108112
unset curlStatus
109113
unset jqStatus
@@ -113,8 +117,8 @@ jobs:
113117
echo "Failed to fetch download URLs"
114118
exit 1
115119
fi
116-
echo "$urls" | xargs wget
117-
wget https://raw.githubusercontent.com/arangodb/docs-hugo/$CIRCLE_SHA1/site/data/versions.yaml
120+
echo "$urls" | xargs -n 1 curl -sS -O -H "Authorization: Bearer $CIRCLECI_GITHUB_READONLY"
121+
curl -sS -O -H "Authorization: Bearer $CIRCLECI_GITHUB_READONLY" https://raw.githubusercontent.com/arangodb/docs-hugo/$CIRCLE_SHA1/site/data/versions.yaml
118122
119123
pip install pyyaml requests
120124

0 commit comments

Comments
 (0)