ci(deploy): event-driven prod deploy via Forgejo Actions on push to main
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.
This commit is contained in:
parent
0f124dc4d3
commit
73bffcbab6
1 changed files with 32 additions and 0 deletions
32
.forgejo/workflows/deploy.yml
Normal file
32
.forgejo/workflows/deploy.yml
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue