I maintain a couple of flarum sites and have a decent CI flow that allows me to version changes to my sites and terst major upgrades safely, and ensure the exact thing tested is what hits my production sites.
composer update
and composer require
are run locally against a test dataset.
- Valid changes are
git push
'd to the site's repo.
- CI Pipeline takes over
- Run's composer install against the composer.lock file
- Puts the website into Maintenance mode.
rsync
s the deltas to production server (key directories like assets ignored)
migrate
and cache
commands prime the site for use.
- Take site out of maintenance mode
- Basic smoke test / ensure site is healthy
I'm using CircleCI for this because I love it, and I work there.
version: 2.1
workflows:
publish:
jobs:
- install_and_push
jobs:
install_and_push:
docker:
- image: composer:1.10
steps:
- checkout
- run:
name: Install tools
command: |
apk add rsync wget
- run:
name: Composer install
command: |
composer install --optimize-autoloader --no-dev --no-progress
- add_ssh_keys
- run:
name: Rsync to server
command: |
ssh-keyscan -H -t rsa example.com >> ~/.ssh/known_hosts
ssh username@example.com -C 'mv /home/username/example.com/public/maintenance.off /home/username/example.com/public/maintenance.html'
rsync -avz ./ username@example.com:/home/username/example.com/
ssh username@example.com -C 'php example.com/flarum migrate && php example.com/flarum cache:clear'
ssh username@example.com -C 'mv /home/username/example.com/public/maintenance.html /home/username/example.com/public/maintenance.off'
wget -p "https://example.com"
The Maintenance uses classic apache/nginx trick to redirect if a file is present.
location / {
if (-f $document_root/maintenance.html) {
return 503;
}
try_files $uri $uri/ /index.php?$query_string;
}
...
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /maintenance.html break;
}