merge dispatch and deploy into a single deploy.sh
deploy.sh reads SSH_ORIGINAL_COMMAND directly, validates it, and runs the deploy. No more dispatch indirection.
This commit is contained in:
@@ -11,8 +11,7 @@ docker/ # One directory per app, each with a compose.yml
|
||||
nginx/ # Nginx Proxy Manager (reverse proxy + TLS)
|
||||
timothykim.net/ # timothykim.net static site
|
||||
scripts/
|
||||
deploy-dispatch.sh # SSH command dispatcher (validates and routes deploy commands)
|
||||
deploy.sh # Generic deploy script (git pull + docker compose up)
|
||||
deploy.sh # Deploy script (validates command, git pull, docker compose up)
|
||||
new-app.sh # Scaffolding script to add a new app
|
||||
setup.sh # One-time server provisioning script
|
||||
.gitea/workflows/ # Per-app deploy workflows triggered by path changes
|
||||
@@ -47,10 +46,10 @@ Each app has two components:
|
||||
1. **Gitea Actions workflow** (`.gitea/workflows/deploy-<app>.yml`) -- triggers
|
||||
on pushes to `main` when files under `docker/<app>/` change. SSHes into the
|
||||
server as the `deploy` user to trigger the deploy.
|
||||
2. **SSH dispatcher** (`scripts/deploy-dispatch.sh`) -- the `deploy` user's
|
||||
2. **Deploy script** (`scripts/deploy.sh`) -- the `deploy` user's
|
||||
`authorized_keys` is locked to this script via a `command=` directive. It
|
||||
validates the command and runs `scripts/deploy.sh`, which pulls the latest
|
||||
repo changes and runs `docker compose pull && up -d` for that app.
|
||||
validates the command, pulls the latest repo changes, and runs
|
||||
`docker compose pull && up -d` for that app.
|
||||
|
||||
This means:
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ "$SSH_ORIGINAL_COMMAND" =~ ^deploy-[a-zA-Z0-9._-]+$ ]]; then
|
||||
sudo /opt/hantim/scripts/deploy.sh "$SSH_ORIGINAL_COMMAND"
|
||||
else
|
||||
echo "Unknown command: $SSH_ORIGINAL_COMMAND"
|
||||
exit 1
|
||||
fi
|
||||
+9
-1
@@ -1,6 +1,14 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
APP="${1#deploy-}"
|
||||
|
||||
CMD="${SSH_ORIGINAL_COMMAND:-${1:-}}"
|
||||
|
||||
if ! [[ "$CMD" =~ ^deploy-[a-zA-Z0-9._-]+$ ]]; then
|
||||
echo "Unknown command: $CMD"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
APP="${CMD#deploy-}"
|
||||
cd /opt/hantim
|
||||
git pull
|
||||
cd "docker/$APP"
|
||||
|
||||
@@ -84,7 +84,7 @@ mkdir -p /home/deploy/.ssh
|
||||
chmod 700 /home/deploy/.ssh
|
||||
if [ ! -f /home/deploy/.ssh/authorized_keys ]; then
|
||||
echo "WARNING: Add the CI public key manually:"
|
||||
echo ' command="/opt/hantim/scripts/deploy-dispatch.sh",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-ed25519 <KEY>'
|
||||
echo ' command="sudo /opt/hantim/scripts/deploy.sh",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-ed25519 <KEY>'
|
||||
echo " into /home/deploy/.ssh/authorized_keys"
|
||||
fi
|
||||
chown -R deploy:deploy /home/deploy/.ssh
|
||||
|
||||
Reference in New Issue
Block a user