Skip to content

Deployment

Deployments are handled via GitHub Actions, using shared reusable workflows from subscribed-aps/workflows.

How it works

The backend lives in backend/ in the monorepo subscribed-aps/elome. The server still runs from a checkout of subscribed-aps/elome-com-bedrock, with Docker Compose, .env and system/releases at the root of that checkout. That repo is now a deploy mirror: nobody commits to it by hand.

.github/workflows/deploy-backend.yml in the monorepo:

  1. Commits the current backend/ tree on top of the mirror branch and pushes it. The push is always a fast-forward, so the server's git pull --ff-only keeps working. The mirror gets one commit per deploy, which links to the source commit in the monorepo.
  2. Calls subscribed-aps/workflows/.github/workflows/deploy-bedrock.yml@main, which pulls the mirror on the server over SSH and runs the deployment script.
  3. On production, posts to the Asana tasks of PRs that changed backend/ and creates a backend/v… release.

The mirror is temporary. README.md in backend/ describes how to phase it out: ship a build to the server instead of git pull, or check out the monorepo with only backend/.

Triggering a Deploy

  1. Go to Actions → Deploy Backend in subscribed-aps/elome
  2. Click Run workflow
  3. Select the target environment: develop or master. For staging you can enter a branch in ref to deploy that branch instead of develop.
  4. Click Run workflow

Environments

Branch Environment Notes
develop Staging Deployed on demand
master Production Deployed on demand

Submodules

backend/.gitmodules must stay in the repo even though git only reads the root .gitmodules in the monorepo. The mirror is built from backend/, and the server needs .gitmodules at the root of its checkout. Keep the two files in sync when a submodule changes.

Deploy keys

php-entrypoint.sh reads SETASIGN_TOKEN from the project root .env on every deploy. The project root is mounted read-only in the php container at /run/project. To add or change one of these keys, edit the root .env and run the deploy. You don't need to recreate the container. To revoke a key, set it to an empty value (SETASIGN_TOKEN=). The deploy then removes the stored Composer login.

The keys are only used for the Composer config during the deploy. WordPress loads its settings the same way as before.

Recreating the php container

The releases live in system/releases and survive a recreate. The current symlink lives inside the container and does not. When php or nginx starts without one, devops/restore-current.sh points current at the newest release where php-entrypoint.sh ran to the end. The entrypoint marks such a release with .release-complete. While a deploy is running, the release has .release-incomplete, so a release whose deploy failed is skipped, also by the fallback. Releases from before the marker existed fall back to the newest one that has vendor/ and WordPress core. The site keeps running on the last good release until the next deploy.

docker compose up -d --force-recreate php
docker compose exec nginx nginx -s reload                          # nginx looks up the new php container's IP
docker compose exec php readlink /var/www/elome/current   # shows which release is live

Only php has to be recreated. nginx resolves the php hostname once at startup, so it needs a reload (no downtime), not a recreate. php-entrypoint.sh is built into the image, so changes to it need --build on the recreate.

The first time you recreate php after this change, mark the live release first. Run this while php still has its current symlink. Then a newer release that failed after Composer can't be picked by the fallback:

docker compose exec php sh -c 'touch "$(readlink -f /var/www/elome/current)/.release-complete"'

Required Secrets

Configured on subscribed-aps/elome and inherited by the reusable workflows:

Secret Description
BACKEND_MIRROR_DEPLOY_KEY Private part of a deploy key with write access to elome-com-bedrock
DOTENV_KEY Key to decrypt .env.vault at deploy time
ASANA_TOKEN Asana notifications on production deploys
HANDBOOK_DISPATCH_TOKEN Token for notifying the Engineering Handbook on docs changes

The SSH and Cloudflare Access values deploy-bedrock.yml uses (DEV_SSH_KEY, PROD_SSH_KEY, CF_ACCESS_CLIENT_ID, CF_ACCESS_CLIENT_SECRET, and the variables DEV_USER, DEV_SSH_URL, DEV_PROJECT, PROD_USER, PROD_SSH_URL, PROD_PROJECT) are configured the same way.

Engineering Handbook Notifications

Changes to backend/docs/ or frontend/docs/ pushed to master notify the Engineering Handbook via .github/workflows/notify-handbook.yml at the repo root.