kenn-io--agentsview
f99010fae1
CI / lint (push) Failing after 1s
CI / frontend (push) Failing after 1s
CI / scripts (push) Failing after 1s
CI / Go Test (ubuntu-latest) (push) Failing after 0s
CI / frontend-node-25 (push) Failing after 1s
CI / docs (push) Failing after 0s
CI / coverage (push) Failing after 0s
CI / e2e (push) Failing after 0s
Docker / build-and-push (push) Failing after 1s
CI / integration (push) Failing after 4m43s
CI / Go Test (windows-latest) (push) Has been cancelled
CI / Desktop Unit Tests (Windows) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux (arm64)) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Windows) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (aarch64)) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (x86_64)) (push) Has been cancelled
116 行
2.9 KiB
Bash
可执行文件
116 行
2.9 KiB
Bash
可执行文件
#!/usr/bin/env bash
|
|
# Update the docs-assets orphan branch from hydrated static docs assets.
|
|
set -euo pipefail
|
|
|
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
docs_root="$(cd "$script_dir/.." && pwd)"
|
|
repo_root="$(cd "$docs_root/.." && pwd)"
|
|
assets_branch="${AGENTSVIEW_DOCS_ASSETS_BRANCH:-docs-assets}"
|
|
source_dir="${AGENTSVIEW_DOCS_STATIC_ASSETS_DIR:-$docs_root/assets/static}"
|
|
push=false
|
|
|
|
expected_assets=(
|
|
"architecture.svg"
|
|
"og-image.png"
|
|
)
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
Usage: $(basename "$0") [--source DIR] [--push]
|
|
|
|
Update the local $assets_branch branch to a single orphan commit containing
|
|
curated static docs assets. Pass --push to force-push that branch to origin.
|
|
EOF
|
|
}
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--source)
|
|
[[ $# -ge 2 ]] || { printf 'ERROR: --source requires a directory\n' >&2; exit 2; }
|
|
source_dir="$2"
|
|
shift 2
|
|
;;
|
|
--push)
|
|
push=true
|
|
shift
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
printf 'unknown option: %s\n' "$1" >&2
|
|
usage >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
done
|
|
|
|
source_dir="$(cd "$source_dir" 2>/dev/null && pwd)" || {
|
|
printf 'static docs asset source does not exist: %s\n' "$source_dir" >&2
|
|
exit 1
|
|
}
|
|
|
|
for asset in "${expected_assets[@]}"; do
|
|
if [[ -L "$source_dir/$asset" ]]; then
|
|
printf 'static docs asset source must not be a symlink: %s\n' "$asset" >&2
|
|
exit 1
|
|
fi
|
|
if [[ ! -f "$source_dir/$asset" ]]; then
|
|
printf 'static docs asset source is missing expected asset: %s\n' "$asset" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
is_expected_asset() {
|
|
local path="$1"
|
|
local asset
|
|
for asset in "${expected_assets[@]}"; do
|
|
[[ "$asset" == "$path" ]] && return 0
|
|
done
|
|
return 1
|
|
}
|
|
|
|
while IFS= read -r -d '' path; do
|
|
rel="${path#"$source_dir"/}"
|
|
case "$rel" in
|
|
.DS_Store|*/.DS_Store)
|
|
continue
|
|
;;
|
|
esac
|
|
if ! is_expected_asset "$rel"; then
|
|
printf 'static docs asset source has unexpected file: %s\n' "$rel" >&2
|
|
exit 1
|
|
fi
|
|
done < <(find "$source_dir" -mindepth 1 \( -type f -o -type l \) -print0)
|
|
|
|
tmp_root="$(mktemp -d)"
|
|
asset_repo="$tmp_root/assets-repo"
|
|
|
|
cleanup() {
|
|
rm -rf "$tmp_root"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
mkdir -p "$asset_repo"
|
|
for asset in "${expected_assets[@]}"; do
|
|
mkdir -p "$asset_repo/$(dirname "$asset")"
|
|
cp "$source_dir/$asset" "$asset_repo/$asset"
|
|
done
|
|
|
|
git -C "$asset_repo" init --quiet
|
|
git -C "$asset_repo" add .
|
|
git -C "$asset_repo" \
|
|
-c user.name="${GIT_AUTHOR_NAME:-agentsview docs bot}" \
|
|
-c user.email="${GIT_AUTHOR_EMAIL:-docs-bot@example.invalid}" \
|
|
commit -m "docs assets" >/dev/null
|
|
asset_commit="$(git -C "$asset_repo" rev-parse HEAD)"
|
|
git -C "$asset_repo" update-ref refs/heads/assets "$asset_commit"
|
|
git -C "$repo_root" fetch "$asset_repo" "+refs/heads/assets:refs/heads/$assets_branch" >/dev/null
|
|
|
|
printf 'Updated %s -> %s\n' "$assets_branch" "$asset_commit"
|
|
|
|
if [[ "$push" == true ]]; then
|
|
git -C "$repo_root" push --force origin "$assets_branch"
|
|
fi
|