CaRMen

· Lars Nielsen

A Backup Script Where a Failed Dump Can't Look Like a Backup: pipefail, Temp Files and Per-Label Retention

CaRMen, my CRM, has a backup script that's 22 lines long. It runs every night from cron and before every deploy, and the deploy script restores from it automatically when a release changes the schema and then fails its health check. A script that a rollback depends on has to be right in the boring details. Three of them are worth spelling out.

Read article A Backup Script Where a Failed Dump Can't Look Like a Backup: pipefail, Temp Files and Per-Label Retention
· Lars Nielsen

An SSH Deploy Key for CI That Can Only Run Two Commands: authorized_keys command= and SSH_ORIGINAL_COMMAND

CaRMen's deploys start in GitHub Actions and end on a server, and something has to cross that gap. Here it's an SSH key, stored as a secret in the repository, that the deploy job uses to connect to the server and run the deploy. A key like that is exactly the kind of secret that leaks: it sits in a CI system, it's used automatically, and nobody watches each use. So the key can't open a shell.

Read article An SSH Deploy Key for CI That Can Only Run Two Commands: authorized_keys command= and SSH_ORIGINAL_COMMAND
· Lars Nielsen

GitHub Actions Can't SSH to My Server: Retrying on Exit 255 and a Server-Side Deploy Fallback

CaRMen's deploys run from GitHub Actions: once the tests pass on the main branch, a job builds and publishes the Docker images, and a deploy job connects to the server over SSH and tells it to switch to the new version. Within a day of setting that up, the deploy job started failing some of the time with SSH errors, while the images it was meant to deploy had been published just fine.

Read article GitHub Actions Can't SSH to My Server: Retrying on Exit 255 and a Server-Side Deploy Fallback
· Lars Nielsen

Environment Variables Not Reaching PHP in GitHub Actions: setup-php, variables_order and php -S

When I moved CaRMen's Playwright tests into GitHub Actions, every login test failed. Partway through each test, the login page redirected to the first-run installer, as if the database were empty. It wasn't. The PHP backend wasn't looking at the database the job had set up at all, because it never saw the environment variables that pointed to it.

Read article Environment Variables Not Reaching PHP in GitHub Actions: setup-php, variables_order and php -S
Subscribe to CaRMen