diff --git a/.github/scripts/download_packages.sh b/.github/scripts/download_packages.sh index 31855ed..bd19939 100755 --- a/.github/scripts/download_packages.sh +++ b/.github/scripts/download_packages.sh @@ -98,8 +98,18 @@ echo "Downloading packages from $REPO releases" # makes stale versions look supported. # --------------------------------------------------------------------------- +# Unauthenticated calls share 60 requests/hour per runner IP and fail CI at random. +github_api() { + if [ -n "${GH_TOKEN:-}" ]; then + # Header via stdin keeps the token out of argv. + curl -fqs -H @- "$@" <<<"Authorization: Bearer $GH_TOKEN" + else + curl -fqs "$@" + fi +} + RELEASES_JSON=$(mktemp) -if ! curl -fqs "https://api.github.com/repos/${REPO}/releases?per_page=100" > "$RELEASES_JSON"; then +if ! github_api "https://api.github.com/repos/${REPO}/releases?per_page=100" > "$RELEASES_JSON"; then echo "Error: Could not fetch release list" exit 1 fi @@ -221,7 +231,7 @@ mkdir -p out/packages for tag in "$PRIMARY_TAG"; do - if ! release=$(curl -fqs "https://api.github.com/repos/${REPO}/releases/tags/$tag"); then + if ! release=$(github_api "https://api.github.com/repos/${REPO}/releases/tags/$tag"); then echo "::error::Could not fetch selected release $tag" exit 1 fi @@ -328,7 +338,7 @@ rm -f "$RELEASES_JSON" "$SEEN_FILE" # release-info.json describes the primary release only: it is the "what is the # current version" feed for the site, not an inventory of the pool. -release=$(curl -fqs "https://api.github.com/repos/${REPO}/releases/tags/${PRIMARY_TAG}") +# $release still holds PRIMARY_TAG from the download loop. echo "$release" | python3 -c " import sys, json data = json.load(sys.stdin) diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index 5c98d97..b046b23 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -180,6 +180,8 @@ jobs: fi - name: Download DocumentDB packages for the stable and latest channels if: steps.features.outputs.packages == 'true' + env: + GH_TOKEN: ${{ github.token }} run: | set -euo pipefail .github/scripts/download_packages.sh diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 8049d0f..2aab0ed 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -99,6 +99,7 @@ jobs: - name: Generate stable from v1.0-0 and latest from the newest release env: DOCUMENTDB_VERSION: v1.0-0 + GH_TOKEN: ${{ github.token }} run: | set -euo pipefail .github/scripts/download_packages.sh