Merge pull request 'fix: Push to public mirrors after merge (#614)' (#621) from fix/issue-614 into main
This commit is contained in:
commit
e041b20823
10 changed files with 105 additions and 2 deletions
|
|
@ -99,6 +99,7 @@ echo "=== 2/2 Function resolution ==="
|
||||||
# lib/file-action-issue.sh — sourced by gardener-run.sh (file_action_issue)
|
# lib/file-action-issue.sh — sourced by gardener-run.sh (file_action_issue)
|
||||||
# lib/secret-scan.sh — sourced by file-action-issue.sh, phase-handler.sh (scan_for_secrets, redact_secrets)
|
# lib/secret-scan.sh — sourced by file-action-issue.sh, phase-handler.sh (scan_for_secrets, redact_secrets)
|
||||||
# lib/formula-session.sh — sourced by formula-driven agents (acquire_cron_lock, run_formula_and_monitor, etc.)
|
# lib/formula-session.sh — sourced by formula-driven agents (acquire_cron_lock, run_formula_and_monitor, etc.)
|
||||||
|
# lib/mirrors.sh — sourced by merge sites (mirror_push)
|
||||||
#
|
#
|
||||||
# Excluded — not sourced inline by agents:
|
# Excluded — not sourced inline by agents:
|
||||||
# lib/ci-debug.sh — standalone CLI tool, run directly (not sourced)
|
# lib/ci-debug.sh — standalone CLI tool, run directly (not sourced)
|
||||||
|
|
@ -109,7 +110,7 @@ echo "=== 2/2 Function resolution ==="
|
||||||
# If a new lib file is added and sourced by agents, add it to LIB_FUNS below
|
# If a new lib file is added and sourced by agents, add it to LIB_FUNS below
|
||||||
# and add a check_script call for it in the lib files section further down.
|
# and add a check_script call for it in the lib files section further down.
|
||||||
LIB_FUNS=$(
|
LIB_FUNS=$(
|
||||||
for f in lib/agent-session.sh lib/env.sh lib/ci-helpers.sh lib/load-project.sh lib/secret-scan.sh lib/file-action-issue.sh lib/formula-session.sh; do
|
for f in lib/agent-session.sh lib/env.sh lib/ci-helpers.sh lib/load-project.sh lib/secret-scan.sh lib/file-action-issue.sh lib/formula-session.sh lib/mirrors.sh; do
|
||||||
if [ -f "$f" ]; then get_fns "$f"; fi
|
if [ -f "$f" ]; then get_fns "$f"; fi
|
||||||
done | sort -u
|
done | sort -u
|
||||||
)
|
)
|
||||||
|
|
@ -179,6 +180,7 @@ check_script lib/secret-scan.sh
|
||||||
check_script lib/file-action-issue.sh lib/secret-scan.sh
|
check_script lib/file-action-issue.sh lib/secret-scan.sh
|
||||||
check_script lib/formula-session.sh lib/agent-session.sh
|
check_script lib/formula-session.sh lib/agent-session.sh
|
||||||
check_script lib/load-project.sh
|
check_script lib/load-project.sh
|
||||||
|
check_script lib/mirrors.sh
|
||||||
|
|
||||||
# Standalone lib scripts (not sourced by agents; run directly or as services).
|
# Standalone lib scripts (not sourced by agents; run directly or as services).
|
||||||
# Still checked for function resolution against LIB_FUNS + own definitions.
|
# Still checked for function resolution against LIB_FUNS + own definitions.
|
||||||
|
|
|
||||||
22
bin/disinto
22
bin/disinto
|
|
@ -505,6 +505,10 @@ containers = []
|
||||||
check_prs = true
|
check_prs = true
|
||||||
check_dev_agent = true
|
check_dev_agent = true
|
||||||
check_pipeline_stall = false
|
check_pipeline_stall = false
|
||||||
|
|
||||||
|
# [mirrors]
|
||||||
|
# github = "git@github.com:user/repo.git"
|
||||||
|
# codeberg = "git@codeberg.org:user/repo.git"
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -894,6 +898,24 @@ p.write_text(text)
|
||||||
# Install cron jobs
|
# Install cron jobs
|
||||||
install_cron "$project_name" "$toml_path" "$auto_yes"
|
install_cron "$project_name" "$toml_path" "$auto_yes"
|
||||||
|
|
||||||
|
# Set up mirror remotes if [mirrors] configured in TOML
|
||||||
|
source "${FACTORY_ROOT}/lib/load-project.sh" "$toml_path"
|
||||||
|
if [ -n "${MIRROR_NAMES:-}" ]; then
|
||||||
|
echo "Mirrors: setting up remotes"
|
||||||
|
local mname murl
|
||||||
|
for mname in $MIRROR_NAMES; do
|
||||||
|
murl=$(eval "echo \"\$MIRROR_$(echo "$mname" | tr '[:lower:]' '[:upper:]')\"") || true
|
||||||
|
[ -z "$murl" ] && continue
|
||||||
|
git -C "$repo_root" remote add "$mname" "$murl" 2>/dev/null \
|
||||||
|
|| git -C "$repo_root" remote set-url "$mname" "$murl" 2>/dev/null || true
|
||||||
|
echo " + ${mname} -> ${murl}"
|
||||||
|
done
|
||||||
|
# Initial sync: push current primary branch to mirrors
|
||||||
|
source "${FACTORY_ROOT}/lib/mirrors.sh"
|
||||||
|
export PROJECT_REPO_ROOT="$repo_root"
|
||||||
|
mirror_push
|
||||||
|
fi
|
||||||
|
|
||||||
# Encrypt secrets if SOPS + age are available
|
# Encrypt secrets if SOPS + age are available
|
||||||
write_secrets_encrypted
|
write_secrets_encrypted
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ set -euo pipefail
|
||||||
export PROJECT_TOML="${1:-}"
|
export PROJECT_TOML="${1:-}"
|
||||||
source "$(dirname "$0")/../lib/env.sh"
|
source "$(dirname "$0")/../lib/env.sh"
|
||||||
source "$(dirname "$0")/../lib/ci-helpers.sh"
|
source "$(dirname "$0")/../lib/ci-helpers.sh"
|
||||||
|
# shellcheck source=../lib/mirrors.sh
|
||||||
|
source "$(dirname "$0")/../lib/mirrors.sh"
|
||||||
|
|
||||||
# Gitea labels API requires []int64 — look up the "underspecified" label ID once
|
# Gitea labels API requires []int64 — look up the "underspecified" label ID once
|
||||||
UNDERSPECIFIED_LABEL_ID=$(forge_api GET "/labels" 2>/dev/null \
|
UNDERSPECIFIED_LABEL_ID=$(forge_api GET "/labels" 2>/dev/null \
|
||||||
|
|
@ -206,6 +208,11 @@ try_direct_merge() {
|
||||||
else
|
else
|
||||||
matrix_send "dev" "✅ PR #${pr_num} merged directly by dev-poll (chore)" 2>/dev/null || true
|
matrix_send "dev" "✅ PR #${pr_num} merged directly by dev-poll (chore)" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
# Pull merged primary branch and push to mirrors
|
||||||
|
git -C "${PROJECT_REPO_ROOT:-}" fetch origin "${PRIMARY_BRANCH:-}" 2>/dev/null || true
|
||||||
|
git -C "${PROJECT_REPO_ROOT:-}" checkout "${PRIMARY_BRANCH:-}" 2>/dev/null || true
|
||||||
|
git -C "${PROJECT_REPO_ROOT:-}" pull --ff-only origin "${PRIMARY_BRANCH:-}" 2>/dev/null || true
|
||||||
|
mirror_push
|
||||||
# Clean up CI fix tracker
|
# Clean up CI fix tracker
|
||||||
ci_fix_reset "$pr_num"
|
ci_fix_reset "$pr_num"
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ source "$(dirname "${BASH_SOURCE[0]}")/../lib/secret-scan.sh"
|
||||||
# shellcheck source=../lib/ci-helpers.sh
|
# shellcheck source=../lib/ci-helpers.sh
|
||||||
source "$(dirname "${BASH_SOURCE[0]}")/../lib/ci-helpers.sh"
|
source "$(dirname "${BASH_SOURCE[0]}")/../lib/ci-helpers.sh"
|
||||||
|
|
||||||
|
# Load mirror push helper
|
||||||
|
# shellcheck source=../lib/mirrors.sh
|
||||||
|
source "$(dirname "${BASH_SOURCE[0]}")/../lib/mirrors.sh"
|
||||||
|
|
||||||
# --- Default globals (agents can override after sourcing) ---
|
# --- Default globals (agents can override after sourcing) ---
|
||||||
: "${CI_POLL_TIMEOUT:=1800}"
|
: "${CI_POLL_TIMEOUT:=1800}"
|
||||||
: "${REVIEW_POLL_TIMEOUT:=10800}"
|
: "${REVIEW_POLL_TIMEOUT:=10800}"
|
||||||
|
|
@ -549,6 +553,11 @@ Instructions:
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
"${API}/issues/${ISSUE}" \
|
"${API}/issues/${ISSUE}" \
|
||||||
-d '{"state":"closed"}' >/dev/null 2>&1 || true
|
-d '{"state":"closed"}' >/dev/null 2>&1 || true
|
||||||
|
# Pull merged primary branch and push to mirrors
|
||||||
|
git -C "$PROJECT_REPO_ROOT" fetch origin "$PRIMARY_BRANCH" 2>/dev/null || true
|
||||||
|
git -C "$PROJECT_REPO_ROOT" checkout "$PRIMARY_BRANCH" 2>/dev/null || true
|
||||||
|
git -C "$PROJECT_REPO_ROOT" pull --ff-only origin "$PRIMARY_BRANCH" 2>/dev/null || true
|
||||||
|
mirror_push
|
||||||
printf 'PHASE:done\n' > "$PHASE_FILE"
|
printf 'PHASE:done\n' > "$PHASE_FILE"
|
||||||
elif [ "$_merge_rc" -ne 2 ]; then
|
elif [ "$_merge_rc" -ne 2 ]; then
|
||||||
# Other merge failure (conflict, etc.) — delegate to Claude for rebase + retry
|
# Other merge failure (conflict, etc.) — delegate to Claude for rebase + retry
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ source "$FACTORY_ROOT/lib/agent-session.sh"
|
||||||
source "$FACTORY_ROOT/lib/formula-session.sh"
|
source "$FACTORY_ROOT/lib/formula-session.sh"
|
||||||
# shellcheck source=../lib/ci-helpers.sh
|
# shellcheck source=../lib/ci-helpers.sh
|
||||||
source "$FACTORY_ROOT/lib/ci-helpers.sh"
|
source "$FACTORY_ROOT/lib/ci-helpers.sh"
|
||||||
|
# shellcheck source=../lib/mirrors.sh
|
||||||
|
source "$FACTORY_ROOT/lib/mirrors.sh"
|
||||||
|
|
||||||
LOG_FILE="$SCRIPT_DIR/gardener.log"
|
LOG_FILE="$SCRIPT_DIR/gardener.log"
|
||||||
# shellcheck disable=SC2034 # consumed by run_formula_and_monitor
|
# shellcheck disable=SC2034 # consumed by run_formula_and_monitor
|
||||||
|
|
@ -292,6 +294,11 @@ _gardener_merge() {
|
||||||
|
|
||||||
if [ "$merge_http_code" = "200" ] || [ "$merge_http_code" = "204" ]; then
|
if [ "$merge_http_code" = "200" ] || [ "$merge_http_code" = "204" ]; then
|
||||||
log "gardener PR #${_GARDENER_PR} merged"
|
log "gardener PR #${_GARDENER_PR} merged"
|
||||||
|
# Pull merged primary branch and push to mirrors
|
||||||
|
git -C "$PROJECT_REPO_ROOT" fetch origin "$PRIMARY_BRANCH" 2>/dev/null || true
|
||||||
|
git -C "$PROJECT_REPO_ROOT" checkout "$PRIMARY_BRANCH" 2>/dev/null || true
|
||||||
|
git -C "$PROJECT_REPO_ROOT" pull --ff-only origin "$PRIMARY_BRANCH" 2>/dev/null || true
|
||||||
|
mirror_push
|
||||||
_gardener_execute_manifest
|
_gardener_execute_manifest
|
||||||
printf 'PHASE:done\n' > "$PHASE_FILE"
|
printf 'PHASE:done\n' > "$PHASE_FILE"
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -304,6 +311,11 @@ _gardener_merge() {
|
||||||
"${FORGE_API}/pulls/${_GARDENER_PR}" | jq -r '.merged // false') || true
|
"${FORGE_API}/pulls/${_GARDENER_PR}" | jq -r '.merged // false') || true
|
||||||
if [ "$pr_merged" = "true" ]; then
|
if [ "$pr_merged" = "true" ]; then
|
||||||
log "gardener PR #${_GARDENER_PR} already merged"
|
log "gardener PR #${_GARDENER_PR} already merged"
|
||||||
|
# Pull merged primary branch and push to mirrors
|
||||||
|
git -C "$PROJECT_REPO_ROOT" fetch origin "$PRIMARY_BRANCH" 2>/dev/null || true
|
||||||
|
git -C "$PROJECT_REPO_ROOT" checkout "$PRIMARY_BRANCH" 2>/dev/null || true
|
||||||
|
git -C "$PROJECT_REPO_ROOT" pull --ff-only origin "$PRIMARY_BRANCH" 2>/dev/null || true
|
||||||
|
mirror_push
|
||||||
_gardener_execute_manifest
|
_gardener_execute_manifest
|
||||||
printf 'PHASE:done\n' > "$PHASE_FILE"
|
printf 'PHASE:done\n' > "$PHASE_FILE"
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
# PROJECT_NAME, FORGE_REPO, FORGE_API, FORGE_WEB, FORGE_URL,
|
# PROJECT_NAME, FORGE_REPO, FORGE_API, FORGE_WEB, FORGE_URL,
|
||||||
# PROJECT_REPO_ROOT, PRIMARY_BRANCH, WOODPECKER_REPO_ID,
|
# PROJECT_REPO_ROOT, PRIMARY_BRANCH, WOODPECKER_REPO_ID,
|
||||||
# PROJECT_CONTAINERS, CHECK_PRS, CHECK_DEV_AGENT,
|
# PROJECT_CONTAINERS, CHECK_PRS, CHECK_DEV_AGENT,
|
||||||
# CHECK_PIPELINE_STALL, CI_STALE_MINUTES
|
# CHECK_PIPELINE_STALL, CI_STALE_MINUTES,
|
||||||
|
# MIRROR_NAMES, MIRROR_URLS, MIRROR_<NAME> (per configured mirror)
|
||||||
# (plus backwards-compat aliases: CODEBERG_REPO, CODEBERG_API, CODEBERG_WEB)
|
# (plus backwards-compat aliases: CODEBERG_REPO, CODEBERG_API, CODEBERG_WEB)
|
||||||
#
|
#
|
||||||
# If no argument given, does nothing (allows poll scripts to work with
|
# If no argument given, does nothing (allows poll scripts to work with
|
||||||
|
|
@ -71,6 +72,14 @@ mon = cfg.get('monitoring', {})
|
||||||
for key in ['check_prs', 'check_dev_agent', 'check_pipeline_stall']:
|
for key in ['check_prs', 'check_dev_agent', 'check_pipeline_stall']:
|
||||||
if key in mon:
|
if key in mon:
|
||||||
emit(key.upper(), mon[key])
|
emit(key.upper(), mon[key])
|
||||||
|
|
||||||
|
# [mirrors] section
|
||||||
|
mirrors = cfg.get('mirrors', {})
|
||||||
|
for name, url in mirrors.items():
|
||||||
|
emit(f'MIRROR_{name.upper()}', url)
|
||||||
|
if mirrors:
|
||||||
|
emit('MIRROR_NAMES', list(mirrors.keys()))
|
||||||
|
emit('MIRROR_URLS', list(mirrors.values()))
|
||||||
" "$_PROJECT_TOML" 2>/dev/null) || {
|
" "$_PROJECT_TOML" 2>/dev/null) || {
|
||||||
echo "WARNING: failed to parse project TOML: $_PROJECT_TOML" >&2
|
echo "WARNING: failed to parse project TOML: $_PROJECT_TOML" >&2
|
||||||
return 1 2>/dev/null || exit 1
|
return 1 2>/dev/null || exit 1
|
||||||
|
|
|
||||||
30
lib/mirrors.sh
Normal file
30
lib/mirrors.sh
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# mirrors.sh — Push primary branch + tags to configured mirror remotes.
|
||||||
|
#
|
||||||
|
# Usage: source lib/mirrors.sh; mirror_push
|
||||||
|
# Requires: PROJECT_REPO_ROOT, PRIMARY_BRANCH, MIRROR_* vars from load-project.sh
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154 # globals set by load-project.sh / calling script
|
||||||
|
|
||||||
|
mirror_push() {
|
||||||
|
[ -z "${MIRROR_NAMES:-}" ] && return 0
|
||||||
|
[ -z "${PROJECT_REPO_ROOT:-}" ] && return 0
|
||||||
|
[ -z "${PRIMARY_BRANCH:-}" ] && return 0
|
||||||
|
|
||||||
|
local name url
|
||||||
|
for name in $MIRROR_NAMES; do
|
||||||
|
url=$(eval "echo \"\$MIRROR_$(echo "$name" | tr '[:lower:]' '[:upper:]')\"") || true
|
||||||
|
[ -z "$url" ] && continue
|
||||||
|
|
||||||
|
# Ensure remote exists with correct URL
|
||||||
|
if git -C "$PROJECT_REPO_ROOT" remote get-url "$name" &>/dev/null; then
|
||||||
|
git -C "$PROJECT_REPO_ROOT" remote set-url "$name" "$url" 2>/dev/null || true
|
||||||
|
else
|
||||||
|
git -C "$PROJECT_REPO_ROOT" remote add "$name" "$url" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fire-and-forget push (background, no failure propagation)
|
||||||
|
git -C "$PROJECT_REPO_ROOT" push "$name" "$PRIMARY_BRANCH" --tags 2>/dev/null &
|
||||||
|
log "mirror: pushed to ${name} (pid $!)"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
@ -25,3 +25,7 @@ token_env = "DISINTO_MATRIX_TOKEN"
|
||||||
check_prs = true
|
check_prs = true
|
||||||
check_dev_agent = true
|
check_dev_agent = true
|
||||||
check_pipeline_stall = false
|
check_pipeline_stall = false
|
||||||
|
|
||||||
|
# [mirrors]
|
||||||
|
# github = "git@github.com:johba/disinto.git"
|
||||||
|
# codeberg = "git@codeberg.org:johba/disinto.git"
|
||||||
|
|
|
||||||
|
|
@ -25,3 +25,7 @@ token_env = "MATRIX_TOKEN"
|
||||||
check_prs = true
|
check_prs = true
|
||||||
check_dev_agent = true
|
check_dev_agent = true
|
||||||
check_pipeline_stall = true
|
check_pipeline_stall = true
|
||||||
|
|
||||||
|
# [mirrors]
|
||||||
|
# github = "git@github.com:johba/harb.git"
|
||||||
|
# codeberg = "git@codeberg.org:johba/harb.git"
|
||||||
|
|
|
||||||
|
|
@ -20,3 +20,7 @@ containers = []
|
||||||
check_prs = true
|
check_prs = true
|
||||||
check_dev_agent = true
|
check_dev_agent = true
|
||||||
check_pipeline_stall = true
|
check_pipeline_stall = true
|
||||||
|
|
||||||
|
# [mirrors]
|
||||||
|
# github = "git@github.com:johba/versi.git"
|
||||||
|
# codeberg = "git@codeberg.org:johba/versi.git"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue