Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 37 lines 1.4 kB view raw
1#!/usr/bin/env bash 2# ac-mirror.sh — bidirectional knot ↔ github mirror for the core repo. 3# Runs via systemd timer every 60s. Idempotent, exits fast when in sync. 4set -euo pipefail 5 6REPO=/opt/ac-mirror/core 7KNOT_KEY=/root/.ssh/knot_push 8GH_KEY=/root/.ssh/github_mirror 9BRANCH=main 10 11cd "$REPO" 12 13export GIT_SSH_COMMAND="ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new \ 14 -i $KNOT_KEY -i $GH_KEY" 15 16# "+" prefix → allow non-fast-forward fetches. A mirror must always track 17# wherever the remote actually is, even after force-pushes or rewinds. 18git fetch --quiet knot "+$BRANCH":refs/remotes/knot/$BRANCH 19git fetch --quiet github "+$BRANCH":refs/remotes/github/$BRANCH 20 21knot_head=$(git rev-parse "knot/$BRANCH") 22gh_head=$(git rev-parse "github/$BRANCH") 23 24if [ "$knot_head" = "$gh_head" ]; then 25 exit 0 26fi 27 28if git merge-base --is-ancestor "$gh_head" "$knot_head"; then 29 echo "$(date -Iseconds) → github behind; pushing $knot_head to github." 30 git push --quiet github "$knot_head:refs/heads/$BRANCH" 31elif git merge-base --is-ancestor "$knot_head" "$gh_head"; then 32 echo "$(date -Iseconds) → knot behind; pushing $gh_head to knot." 33 git push --quiet knot "$gh_head:refs/heads/$BRANCH" 34else 35 echo "$(date -Iseconds) ⚠️ divergent heads: knot=$knot_head github=$gh_head — skipping (manual resolution required)" >&2 36 exit 2 37fi