Skip to content

Deployment

Deployments are handled by GitHub Actions via a shared reusable workflow in subscribed-aps/workflows.

Workflow

File: .github/workflows/deploy-bedrock.yml

Triggered manually via workflow_dispatch with a required environment input (develop or master). It delegates to the shared workflow:

subscribed-aps/workflows/.github/workflows/deploy-bedrock.yml@main

To trigger a deployment, go to Actions → Deploy Bedrock → Run workflow and select the target environment.

Environments

Environment Branch Server path
develop develop /usr/share/wordpress.staging/barberklingen.se/deployments
master master /usr/share/wordpress.barberklingen.se/deployments

Deployment script

The actual deployment logic lives in the devops/deployment-script submodule (bedrock-deployment-script). The shared workflow checks out the repo on the server and runs this script, which:

  1. Checks out the target branch into a new timestamped release directory under system/releases/
  2. Runs composer install
  3. Symlinks the new release to current
  4. Runs WP-CLI migrations (wp barberklingen database migrate)
  5. Prunes old releases (keeps the last 3)

Config changes under devops/ (php.ini, www.conf, nginx)

The files in devops/<env>/php/ and devops/<env>/nginx/ are bind-mounted into the containers (see docker-compose.yml). The deploy workflow above only creates a new application release; it does not restart the containers, and PHP-FPM and nginx read their config at startup. A config change is therefore not live until the containers are restarted.

On the server, after merging:

cd <deployments dir>          # see table above
git pull
docker exec barberklingen-se-php php-fpm -t
docker exec barberklingen-se-nginx nginx -t
docker restart barberklingen-se-php barberklingen-se-nginx

Verify that the running FPM workers picked up the change, for example:

docker exec barberklingen-se-php php -i | grep -E "^memory_limit|upload_progress.enabled"

Image changes (Dockerfile) additionally need docker compose build and docker compose up -d.

Deploy keys

php-entrypoint.sh reads ELEMENTOR_EMAIL, ELEMENTOR_LICENSE and 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 (ELEMENTOR_EMAIL=). The deploy then removes the stored Composer login.

SETASIGN_TOKEN is needed because the DHL shipping package (barberklingen/package-dao-shipping) depends on setasign/fpdi_pdf-parser. Without it composer install fails. Use the same token as Elome.

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/barberklingen/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/barberklingen/current)/.release-complete"'

The entrypoint uses set -e, so a failing step (Composer, the asset build or a migration) stops the deploy instead of letting a half-built release go live.

Required secrets

The following secrets must be set in the GitHub repository settings:

Secret Purpose
HANDBOOK_DISPATCH_TOKEN Used by the handbook notification workflow
(deploy secrets) Defined by the shared workflow in subscribed-aps/workflows

Dotenv Vault

Production environment variables are encrypted via dotenv-vault. The DOTENV_KEY secret is injected at runtime. The .env.vault file is committed to the repository and decrypted on the server using the key.

Legacy: Bitbucket Pipelines

bitbucket-pipelines.yml still exists and imports from bitbucket-master-pipe. This is superseded by the GitHub Actions workflow and can be considered deprecated.