Files
docker-docs/hack/sync-cli-docs.sh
Paweł Gronowski c3652459f9 ci: Add automated CLI documentation sync workflow
This adds a GitHub Actions workflow and supporting script to
automatically sync CLI documentation from the docker/cli repository on a
daily schedule.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-18 21:21:54 +01:00

39 lines
1.2 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
set -euo pipefail
main() {
local branch_name="${1:-upstream/master}"
local cli_source="${2:-$HOME/src/cli}/.git"
local worktree_dir="./internal-update-cli-docs"
(
set -e
GIT_DIR="$cli_source"
GIT_DIR="$GIT_DIR" git fetch upstream
GIT_DIR="$GIT_DIR" git worktree add "$worktree_dir" "$branch_name"
) || return $?
trap "GIT_DIR=\"$cli_source\" git worktree remove \"$worktree_dir\" --force 2>/dev/null || true" EXIT
(set -e; cd "$worktree_dir"; make -f docker.Makefile yamldocs || { printf "::error::Failed to generate YAML docs!\n"; exit 1; }) || return $?
cp "$worktree_dir"/docs/yaml/*.yaml ./data/engine-cli/
if git diff --quiet "./data/engine-cli/*.yaml"; then
printf "\e[32m✅ Already up to date\e[0m\n"
return 100
fi
echo -e " Changes detected:"
git diff --stat "./data/engine-cli/*.yaml" || true
NICE_GIT_REF=$(cd "$worktree_dir" && git describe --always --dirty) || return $?
git add "./data/engine-cli/*.yaml"
git commit -m "cli: sync docs with docker/cli $NICE_GIT_REF"
printf "\e[32m✅ Committed changes\e[0m\n"
return 0
}
main "$@"