mirror of
https://github.com/docker/docs.git
synced 2026-06-19 07:35:16 +00:00
356489df54
Add hack/sync-governance-api.sh to re-vendor the AI Governance Policy API spec from the private docker/governor-services repo. The vendored copy at content/reference/api/ai-governance/api.yaml is a verbatim copy of upstream, so the script fetches it via gh (using the caller's own auth, no repo secrets) and prints a diff summary for review. Mirrors the existing hack/sync-cli-docs.sh convention. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
56 lines
1.8 KiB
Bash
Executable File
56 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Re-vendor the AI Governance OpenAPI spec from docker/governor-services.
|
|
#
|
|
# The spec at content/reference/api/ai-governance/api.yaml is a verbatim copy
|
|
# of the upstream openapi.yaml — no transformation is applied. This script
|
|
# fetches the latest version and overwrites the local copy, then prints a diff
|
|
# summary so you can sanity-check before committing.
|
|
#
|
|
# Requires: gh (authenticated with access to the private docker/governor-services
|
|
# repo). No secrets are stored in this repo — auth comes from your own gh login.
|
|
#
|
|
# Usage: hack/sync-governance-api.sh [ref]
|
|
# ref optional git ref (branch, tag, or SHA). Defaults to the repo default branch.
|
|
set -euo pipefail
|
|
|
|
REPO="docker/governor-services"
|
|
SRC_PATH="governor-service-api/openapi.yaml"
|
|
DEST="content/reference/api/ai-governance/api.yaml"
|
|
REF="${1:-}"
|
|
|
|
# Resolve this repo's root so the script works from any working directory.
|
|
ROOT="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)"
|
|
DEST_ABS="$ROOT/$DEST"
|
|
|
|
if ! command -v gh >/dev/null 2>&1; then
|
|
echo "error: gh CLI not found. Install it and run 'gh auth login'." >&2
|
|
exit 1
|
|
fi
|
|
|
|
api_path="repos/$REPO/contents/$SRC_PATH"
|
|
[ -n "$REF" ] && api_path="$api_path?ref=$REF"
|
|
|
|
echo "Fetching $SRC_PATH from $REPO${REF:+@$REF}..."
|
|
tmp="$(mktemp)"
|
|
trap 'rm -f "$tmp"' EXIT
|
|
|
|
if ! gh api "$api_path" --jq '.content' | base64 -d > "$tmp"; then
|
|
echo "error: failed to fetch spec. Check 'gh auth status' and repo access." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -s "$tmp" ]; then
|
|
echo "error: fetched spec is empty — aborting without overwriting $DEST." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if diff -q "$DEST_ABS" "$tmp" >/dev/null 2>&1; then
|
|
echo "Already up to date — $DEST is identical to upstream."
|
|
exit 0
|
|
fi
|
|
|
|
cp "$tmp" "$DEST_ABS"
|
|
echo "Updated $DEST. Review the change:"
|
|
echo
|
|
git -C "$ROOT" --no-pager diff --stat -- "$DEST"
|