diff --git a/.github/bin/check_boringssl_fork_freshness.sh b/.github/bin/check_boringssl_fork_freshness.sh new file mode 100755 index 00000000000..5b7dee535d5 --- /dev/null +++ b/.github/bin/check_boringssl_fork_freshness.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +set -euo pipefail + +# The script is configurable via environment variablesß +FORK_REPO="${FORK_REPO:-kaukabrizvi/boring}" # owner/repo +FORK_BRANCH="${FORK_BRANCH:-symbol-prefixing}" # branch to check +THRESHOLD_DAYS="${THRESHOLD_DAYS:-60}" # ~2 months + +if ! command -v jq >/dev/null 2>&1; then + echo "ERROR: jq is required for the BoringSSL fork freshness check." + exit 2 +fi + +commit_api="https://api.github.com/repos/${FORK_REPO}/commits/${FORK_BRANCH}" +json="$(curl -fsSL "${commit_api}")" + +last_commit_date="$(echo "${json}" | jq -r '.commit.committer.date')" +last_commit_sha="$(echo "${json}" | jq -r '.sha')" + +if [[ -z "${last_commit_date}" || "${last_commit_date}" == "null" ]]; then + echo "ERROR: Could not determine last commit date for ${FORK_REPO}@${FORK_BRANCH} from GitHub API." + exit 2 +fi + +now_epoch="$(date -u +%s)" +commit_epoch="$(date -u -d "${last_commit_date}" +%s)" +age_days="$(( (now_epoch - commit_epoch) / 86400 ))" + +if (( age_days > THRESHOLD_DAYS )); then + cat <