#!/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 # 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 ==="