From 73bffcbab66dfbbe59d2677c69163b60fe1b0f30 Mon Sep 17 00:00:00 2001 From: npeter83 Date: Sun, 21 Jun 2026 05:20:34 +0200 Subject: [PATCH] ci(deploy): event-driven prod deploy via Forgejo Actions on push to main MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a push to main the server-hosted runner SSHes back to the host (forced-command key, docker bridge gateway, port 2222) and runs deploy/deploy.sh — replacing the 2-minute systemd poller. Build/publish still happens on the dev machine before push. --- .forgejo/workflows/deploy.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .forgejo/workflows/deploy.yml diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml new file mode 100644 index 0000000..9289de8 --- /dev/null +++ b/.forgejo/workflows/deploy.yml @@ -0,0 +1,32 @@ +name: deploy + +# Event-driven production deploy. Replaces the 2-minute systemd poller on asgard: on a push +# to main, the asgard-hosted Forgejo Actions runner connects back to the asgard host over the +# Docker bridge gateway and runs the existing deploy/deploy.sh, which pulls the published image +# and restarts the stack. The image itself is still built and pushed from the developer machine +# (`siftlode publish`) BEFORE the push — this job only triggers the deploy, it does not build. +# +# The SSH key is a dedicated, forced-command key on the host (it can ONLY run deploy.sh), stored +# here as a base64-encoded Actions secret. The host address is the container's default-route +# gateway (= the Docker host), resolved at runtime so no fixed IP or runner config is needed. + +on: + push: + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: trigger host deploy + run: | + command -v ssh >/dev/null 2>&1 || { apt-get update -qq && apt-get install -y -qq openssh-client; } + install -m 700 -d ~/.ssh + printf '%s' "${{ secrets.DEPLOY_SSH_KEY_B64 }}" | base64 -d > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + # Default-route gateway of this job container = the Docker host (little-endian hex in /proc/net/route). + H=$(awk '$2=="00000000" && $1!="lo"{print $3; exit}' /proc/net/route) + HOST=$(printf '%d.%d.%d.%d' "0x${H:6:2}" "0x${H:4:2}" "0x${H:2:2}" "0x${H:0:2}") + echo "Deploying via host $HOST:2222" + ssh -p 2222 -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/dev/null \ + -i ~/.ssh/id_ed25519 "p33t@$HOST" deploy