diff --git a/sync.sh b/sync.sh index b9b79a1e..70be76d3 100755 --- a/sync.sh +++ b/sync.sh @@ -1,11 +1,22 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail -defaultBaseUrl="https://fingerprintjs.github.io/fingerprint-pro-server-api-openapi" -schemaUrl="${1:-$defaultBaseUrl/schemas/fingerprint-server-api-compact.yaml}" +# Resolve paths relative to the repository root, so the script can be run from +# any working directory. +cd "$(dirname "${BASH_SOURCE[0]}")" + +schemaUrl="${1:-https://fingerprintjs.github.io/openapi/schemas/fingerprint-server-api-compact.yaml}" + +CURL_OPTS=(-fSL --retry 3 --proto-redir '=https' --connect-timeout 10 --max-time 300) +if [[ "${TRACE:-}" != "true" && "${ACTIONS_STEP_DEBUG:-}" != "true" ]]; then + CURL_OPTS+=(-s) +fi mkdir -p ./res -curl -fSL --retry 3 -o ./res/fingerprint-server-api.yaml "$schemaUrl" +echo "Downloading $schemaUrl" +curl "${CURL_OPTS[@]}" -o ./res/fingerprint-server-api.yaml "$schemaUrl" + +echo "OpenAPI schema download complete." ./generate.sh