| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
set -e |
| 8 |
|
| 9 |
HETZNER="root@100.120.174.96" |
| 10 |
HETZNER_SSH="-p 2200" |
| 11 |
ASTRA="max@100.106.221.39" |
| 12 |
HOOK_SRC="deploy/post-receive-hook.sh" |
| 13 |
CI_SRC="deploy/ci-on-push.sh" |
| 14 |
|
| 15 |
echo "=== CI Setup ===" |
| 16 |
|
| 17 |
|
| 18 |
echo "[1/5] Generating SSH key for git user on Hetzner..." |
| 19 |
ssh $HETZNER_SSH $HETZNER bash -s <<'REMOTE' |
| 20 |
if [ ! -f /opt/git/.ssh/id_ed25519 ]; then |
| 21 |
sudo -u git ssh-keygen -t ed25519 -f /opt/git/.ssh/id_ed25519 -N "" -C "git@hetzner-ci" |
| 22 |
chown git:git /opt/git/.ssh/id_ed25519 /opt/git/.ssh/id_ed25519.pub |
| 23 |
echo "Key generated." |
| 24 |
else |
| 25 |
echo "Key already exists." |
| 26 |
fi |
| 27 |
cat /opt/git/.ssh/id_ed25519.pub |
| 28 |
REMOTE |
| 29 |
|
| 30 |
|
| 31 |
echo "" |
| 32 |
echo "[2/5] Retrieving public key..." |
| 33 |
PUBKEY=$(ssh $HETZNER_SSH $HETZNER "cat /opt/git/.ssh/id_ed25519.pub") |
| 34 |
echo " $PUBKEY" |
| 35 |
|
| 36 |
|
| 37 |
echo "" |
| 38 |
echo "[3/5] Installing public key on astra..." |
| 39 |
echo " Copy this key to astra's ~/.ssh/authorized_keys:" |
| 40 |
echo "" |
| 41 |
echo " $PUBKEY" |
| 42 |
echo "" |
| 43 |
echo " Run on astra: echo '$PUBKEY' >> /home/max/.ssh/authorized_keys" |
| 44 |
echo "" |
| 45 |
read -p " Press Enter once the key is installed on astra..." |
| 46 |
|
| 47 |
|
| 48 |
echo "" |
| 49 |
echo "[4/5] Deploying post-receive hook..." |
| 50 |
scp $HETZNER_SSH $HOOK_SRC $HETZNER:/opt/git/max/makenotwork.git/hooks/post-receive |
| 51 |
ssh $HETZNER_SSH $HETZNER "chown git:git /opt/git/max/makenotwork.git/hooks/post-receive && chmod +x /opt/git/max/makenotwork.git/hooks/post-receive" |
| 52 |
echo " Hook installed." |
| 53 |
|
| 54 |
|
| 55 |
echo "" |
| 56 |
echo "[5/5] Deploying CI script to astra..." |
| 57 |
echo " Copy $CI_SRC to astra:/home/max/staging/ci-on-push.sh" |
| 58 |
echo " (Cannot scp to astra from here if SSH is down — copy manually)" |
| 59 |
echo "" |
| 60 |
echo " scp $CI_SRC $ASTRA:/home/max/staging/ci-on-push.sh" |
| 61 |
echo " ssh $ASTRA 'chmod +x /home/max/staging/ci-on-push.sh'" |
| 62 |
|
| 63 |
echo "" |
| 64 |
echo "=== Setup Complete ===" |
| 65 |
echo "" |
| 66 |
echo "Test: push a commit to mnw/main and check WAM for a CI ticket." |
| 67 |
|