CI and automatic deployment
GitHub Actions runs .github/workflows/ci-deploy.yml on pull requests, pushes to main and manual dispatch. It checks Python/JavaScript/Bash syntax, builds the application image, runs the full isolated PostgreSQL suite, and retains test logs/reports for seven days. The test environment has no production credentials or real model key, and outbound delivery is disabled.
Successful main runs deploy automatically. Pull requests never deploy or receive deployment secrets. CI checks may supersede old CI jobs; production deployments are serialized and never interrupted by a newer push. The server also uses a filesystem lock and rejects a commit that no longer equals origin/main. Actions dependencies are pinned to commit hashes.
Server flow
Section titled “Server flow”- The restricted SSH deployment command fetches the private repository using the short-lived GitHub Actions token with read-only contents access.
- It verifies the requested 40-character SHA is current main, checks free disk, extracts the commit into a private staging directory and builds a commit-tagged image. Build failures leave production untouched.
- It captures the previous image of each app service, backs up managed source/config files and takes a PostgreSQL dump. Backups are private under
/var/lib/dirman-assist-cd/deployments. - It syncs only application, scripts, docs, tests and selected Compose/build files.
.env, secrets, database volumes, WAHA sessions, proxy configuration and unrelated deployments are preserved. - It validates Compose, runs database migrations, and restarts only api, worker, dashboard, pdf-worker and topic-worker. PostgreSQL and WAHA are never restarted by this script. App restarts can briefly interrupt requests; this is not a zero-downtime rollout.
- It waits for service readiness and checks the public HTTPS health endpoint. Successful commits are recorded in
/var/lib/dirman-assist-cd/deployed-commit.
After a deployment failure, the script restores managed source/config and the previous per-service images. It does not automatically restore the database: that could discard user activity. Schema migrations must remain backward compatible for automatic app rollback to work. Investigate the database dump and migration before any manual restore. Failed build images/releases and deployment backups are retained for operator review; monitor disk usage.
Authentication
Section titled “Authentication”One-time setup uses python scripts/setup-cd.py from the operator machine, with existing root SSH and authenticated GitHub CLI access. It checks the previously approved server ED25519 fingerprint before modifying automation settings. It installs the controller at /usr/local/sbin/dirman-assist-deploy.
GitHub repository secrets are DEPLOY_HOST, DEPLOY_KNOWN_HOSTS and DEPLOY_SSH_KEY. The key’s authorized_keys entry uses restrict and a forced deployment command, with no interactive shell, forwarding or PTY. The workflow passes its repository token through SSH standard input. The server uses it for one HTTPS fetch without saving it. The server SSH host key is pinned. New automation keys are stored under /etc/dirman-assist-cd, outside the application directory. Private keys, .env and database dumps are never committed or printed.
Changing the SSH host key requires verifying and updating the pin and GitHub secret. Rotate/revoke deployment keys through the GitHub Actions secret and the dedicated authorized_keys entry; preserve unrelated operator keys.
Operation
Section titled “Operation”Push or merge an update to main, then inspect the Verify and deploy run in GitHub Actions. Failed CI prevents deployment. To retry, rerun the workflow or manually dispatch it on main. To return to an older application version, revert its commit on main and allow the resulting tested commit to deploy. Arbitrary historical SHAs are intentionally rejected by the SSH endpoint.
Production checks:
cat /var/lib/dirman-assist-cd/deployed-commitdocker compose -f compose.yaml -f compose.dashboard-public.yaml pscurl -fsS https://assist.p3mdi.id/healthNo WhatsApp test messages are sent by CI/CD. Normal authorized production conversations and background jobs continue after the application restart.