63 lines
2.1 KiB
Bash
Executable File
63 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# hugo-content-workspace/v1 finalize.sh
|
|
# Detects and commits any changes made by the agent.
|
|
# Content repo is committed and pushed first, then integration repo.
|
|
set -euo pipefail
|
|
|
|
echo "=== hugo-content-workspace/v1 finalize.sh ==="
|
|
|
|
: "${HUGO_CUSTOMER:?HUGO_CUSTOMER is required}"
|
|
: "${HUGO_CONTENT_BRANCH:=staging}"
|
|
|
|
commit_repo() {
|
|
local repo_dir="$1"
|
|
local branch="$2"
|
|
local label="$3"
|
|
|
|
if [ ! -d "${repo_dir}/.git" ]; then
|
|
echo "${label}: no .git directory, skipping"
|
|
return 0
|
|
fi
|
|
|
|
cd "${repo_dir}"
|
|
|
|
# Check for any modifications (tracked or untracked)
|
|
if git diff --quiet HEAD 2>/dev/null && [ -z "$(git ls-files --others --exclude-standard)" ]; then
|
|
echo "${label}: no changes detected"
|
|
return 0
|
|
fi
|
|
|
|
# Stage all changes
|
|
git add -A
|
|
|
|
# Never commit the agentic runner's scratch: `.agent-output/` (task-complete.json,
|
|
# logs) is written into the CWD, which is the content repo checkout. Committing it
|
|
# produced a junk "AI content update" commit on every AI task — including read-only
|
|
# flows (draft, section-edit) where cms-proxy applies the real change via PATCH — and
|
|
# each junk commit to the content branch triggered a spurious content-CI site rebuild.
|
|
git reset -q -- .agent-output >/dev/null 2>&1 || true
|
|
|
|
# Double-check — after staging, is there anything to commit?
|
|
if git diff --cached --quiet; then
|
|
echo "${label}: nothing staged after add -A"
|
|
return 0
|
|
fi
|
|
|
|
local msg="AI content update — ${HUGO_CUSTOMER} (${HUGO_CONTENT_BRANCH})"
|
|
if [ "${label}" = "integration" ]; then
|
|
msg="AI integration update — ${HUGO_CUSTOMER}"
|
|
fi
|
|
|
|
git commit -m "${msg}"
|
|
git push origin "${branch}"
|
|
echo "${label}: committed and pushed to ${branch}"
|
|
}
|
|
|
|
# 1. Content repo — push to the requested content branch
|
|
commit_repo /workspace/content "${HUGO_CONTENT_BRANCH}" "content"
|
|
|
|
# 2. Integration repo — push to main
|
|
commit_repo /workspace/integration "main" "integration"
|
|
|
|
echo "=== hugo-content-workspace/v1 finalize.sh complete ==="
|