docs: add one-click management deployment and image workflow
management-images / build-and-publish (push) Successful in 9m15s
management-images / build-and-publish (push) Successful in 9m15s
This commit is contained in:
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
source_dir="$root/docs/contracts"
|
||||
target_dir="$root/management/contracts"
|
||||
mkdir -p "$target_dir"
|
||||
files=(sip-management.openapi.yaml cell-agent.openapi.yaml)
|
||||
if [[ "${1:-}" == "--check" ]]; then
|
||||
for file in "${files[@]}"; do
|
||||
cmp -s "$source_dir/$file" "$target_dir/$file" || {
|
||||
echo "contract snapshot is stale: $file" >&2
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
echo "contract snapshots match docs/contracts"
|
||||
exit 0
|
||||
fi
|
||||
for file in "${files[@]}"; do cp "$source_dir/$file" "$target_dir/$file"; done
|
||||
python3 - "$source_dir" "$target_dir" "${files[@]}" <<'PY'
|
||||
import hashlib, json, pathlib, sys
|
||||
source = pathlib.Path(sys.argv[1])
|
||||
target = pathlib.Path(sys.argv[2])
|
||||
files = sys.argv[3:]
|
||||
manifest = {"source": "docs/contracts", "files": {}}
|
||||
for name in files:
|
||||
data = (target / name).read_bytes()
|
||||
manifest["files"][name] = {"source_path": f"docs/contracts/{name}", "sha256": hashlib.sha256(data).hexdigest()}
|
||||
(target / "manifest.json").write_text(json.dumps(manifest, indent=2, ensure_ascii=False) + "\n")
|
||||
PY
|
||||
echo "contract snapshots synchronized"
|
||||
Reference in New Issue
Block a user