Skip to content

Instantly share code, notes, and snippets.

@croxton
Last active July 13, 2023 01:00
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save croxton/0032b604407b64b4d0d49f657523e069 to your computer and use it in GitHub Desktop.
Save croxton/0032b604407b64b4d0d49f657523e069 to your computer and use it in GitHub Desktop.
Buddy.works Craft 3 Atomic deployments
- pipeline: "Build and deploy to [environment]"
trigger_mode: "MANUAL"
ref_name: "master"
actions:
- action: "Execute: gulp build"
type: "BUILD"
docker_image_name: "library/node"
docker_image_tag: "6"
execute_commands:
- "npm install"
- "gulp build"
setup_commands:
- "npm install -g gulp"
trigger_condition: "ALWAYS"
- action: "Execute: composer install"
type: "BUILD"
docker_image_name: "library/php"
docker_image_tag: "7.1"
execute_commands:
- "composer install --no-interaction --prefer-dist --optimize-autoloader"
setup_commands:
- "apt-get update && apt-get install -y git zip"
- "curl -L https://phar.phpunit.de/phpunit.phar -o /usr/local/bin/phpunit"
- "chmod +x /usr/local/bin/phpunit"
- "curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer"
services:
- type: "MYSQL"
version: "5.7"
persistent: true
connection:
host: "mysql"
port: 3306
user: "root"
password: "qwerty"
trigger_condition: "ALWAYS"
- action: "Rsync to ${ssh_ip}"
type: "RSYNC"
local_path: "/"
remote_path: "${remote_path}/deploy-cache"
login: "${ssh_username}"
password: "${ssh_password}"
host: "${ssh_ip}"
port: "22"
authentication_mode: "PASS"
archive: true
delete_extra_files: true
compress: true
deployment_excludes:
- "/.git/"
- "/node_modules/"
- "/storage/"
- "/${webroot}/cpresources/"
- "/${webroot}/uploads/"
- ".env"
trigger_condition: "ALWAYS"
- action: "Post-deployment action"
type: "SSH_COMMAND"
working_directory: "${remote_path}/"
login: "${ssh_username}"
password: "${ssh_password}"
host: "${ssh_ip}"
port: "22"
authentication_mode: "PASS"
commands:
- "if [ -d \"releases/${execution.to_revision.revision}\" ] && [ \"${execution.refresh}\" = \"true\" ]; then echo \"Removing: releases/${execution.to_revision.revision}\" && rm -rf releases/${execution.to_revision.revision}; fi"
- "if [ ! -d \"releases/${execution.to_revision.revision}\" ]; then echo \"Creating: releases/${execution.to_revision.revision}\" && cp -dR deploy-cache releases/${execution.to_revision.revision}; fi"
- "echo \"Creating: persistent directories\""
- "mkdir -p storage/craft"
- "mkdir -p storage/cpresources"
- "mkdir -p storage/uploads"
- "echo \"Symlinking: persistent directories\""
- "ln -nfs ${remote_path}/storage/craft ${remote_path}/releases/${execution.to_revision.revision}/storage"
- "ln -nfs ${remote_path}/storage/cpresources ${remote_path}/releases/${execution.to_revision.revision}/${webroot}/cpresources"
- "ln -nfs ${remote_path}/storage/uploads ${remote_path}/releases/${execution.to_revision.revision}/${webroot}/uploads"
- "echo \"Linking current to revision: ${execution.to_revision.revision}\""
- "rm -f current"
- "ln -s releases/${execution.to_revision.revision} current"
- "echo \"Removing old releases\""
- "cd releases && ls -t | tail -n +4 | xargs rm -rf"
trigger_condition: "ALWAYS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment