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)
|
nginx/ # Nginx Proxy Manager (reverse proxy + TLS)
|
||||||
timothykim.net/ # timothykim.net static site
|
timothykim.net/ # timothykim.net static site
|
||||||
scripts/
|
scripts/
|
||||||
deploy-dispatch.sh # SSH command dispatcher (validates and routes deploy commands)
|
deploy.sh # Deploy script (validates command, git pull, docker compose up)
|
||||||
deploy.sh # Generic deploy script (git pull + docker compose up)
|
|
||||||
new-app.sh # Scaffolding script to add a new app
|
new-app.sh # Scaffolding script to add a new app
|
||||||
setup.sh # One-time server provisioning script
|
setup.sh # One-time server provisioning script
|
||||||
.gitea/workflows/ # Per-app deploy workflows triggered by path changes
|
.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
|
1. **Gitea Actions workflow** (`.gitea/workflows/deploy-<app>.yml`) -- triggers
|
||||||
on pushes to `main` when files under `docker/<app>/` change. SSHes into the
|
on pushes to `main` when files under `docker/<app>/` change. SSHes into the
|
||||||
server as the `deploy` user to trigger the deploy.
|
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
|
`authorized_keys` is locked to this script via a `command=` directive. It
|
||||||
validates the command and runs `scripts/deploy.sh`, which pulls the latest
|
validates the command, pulls the latest repo changes, and runs
|
||||||
repo changes and runs `docker compose pull && up -d` for that app.
|
`docker compose pull && up -d` for that app.
|
||||||
|
|
||||||
This means:
|
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
|
#!/bin/bash
|
||||||
set -euo pipefail
|
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
|
cd /opt/hantim
|
||||||
git pull
|
git pull
|
||||||
cd "docker/$APP"
|
cd "docker/$APP"
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ mkdir -p /home/deploy/.ssh
|
|||||||
chmod 700 /home/deploy/.ssh
|
chmod 700 /home/deploy/.ssh
|
||||||
if [ ! -f /home/deploy/.ssh/authorized_keys ]; then
|
if [ ! -f /home/deploy/.ssh/authorized_keys ]; then
|
||||||
echo "WARNING: Add the CI public key manually:"
|
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"
|
echo " into /home/deploy/.ssh/authorized_keys"
|
||||||
fi
|
fi
|
||||||
chown -R deploy:deploy /home/deploy/.ssh
|
chown -R deploy:deploy /home/deploy/.ssh
|
||||||
|
|||||||
Reference in New Issue
Block a user