Skip to main content

max / makenotwork

1.7 KB · 39 lines History Blame Raw
1 #!/bin/bash
2 # Git post-receive hook for makenotwork.git on Hetzner.
3 #
4 # Handles two events:
5 # 1. Tag push (v*): triggers OTA build via MNW internal API (existing)
6 # 2. Branch push (main): triggers CI on astra via SSH (new)
7 #
8 # Install: copy to /opt/git/max/makenotwork.git/hooks/post-receive
9
10 BUILD_TOKEN="a11d2b9ff121a70e7391b36d00e812da6bba1dd91ed17d4b5e0f0dbb7f7f66cc"
11 # Astra's WAM (Hetzner can reach astra, but not vice versa due to Tailscale ACLs)
12 ASTRA_WAM_URL="http://100.106.221.39:7890"
13
14 while read oldrev newrev refname; do
15 case "$refname" in
16 refs/tags/v[0-9]*)
17 # OTA build trigger (existing behavior)
18 TAG="${refname#refs/tags/}"
19 REPO_PATH="$(cd "$(dirname "$0")/.." && pwd)"
20 REPO_NAME="$(basename "$REPO_PATH" .git)"
21 OWNER="$(basename "$(dirname "$REPO_PATH")")"
22 curl -sf -X POST \
23 -H "Authorization: Bearer $BUILD_TOKEN" \
24 -H "Content-Type: application/json" \
25 -d "{\"repo_owner\": \"$OWNER\", \"repo_name\": \"$REPO_NAME\", \"tag\": \"$TAG\"}" \
26 "http://localhost:3000/api/internal/builds/trigger" \
27 >/dev/null 2>&1 &
28 ;;
29 refs/heads/main)
30 # CI trigger: create a WAM ticket that astra's CI watcher picks up.
31 # Avoids SSH ACL issues — both machines can reach WAM on localhost/tailnet.
32 curl -sf -X POST "$ASTRA_WAM_URL/tickets" \
33 -H "Content-Type: application/json" \
34 -d "{\"title\": \"CI trigger: main pushed ($newrev)\", \"priority\": \"medium\", \"source\": \"ci-trigger\", \"source_ref\": \"$newrev\"}" \
35 >/dev/null 2>&1 &
36 ;;
37 esac
38 done
39