|
| 1 | +- pipeline: "Build & Deploy to Production" |
| 2 | + trigger_mode: "ON_EVERY_PUSH" |
| 3 | + ref_name: "master" |
| 4 | + ref_type: "BRANCH" |
| 5 | + target_site_url: "https://CHANGEME.com/" |
| 6 | + trigger_condition: "ALWAYS" |
| 7 | + actions: |
| 8 | + - action: "Execute: webpack build" |
| 9 | + type: "BUILD" |
| 10 | + working_directory: "/buddy/$PROJECT_SHORTNAME" |
| 11 | + docker_image_name: "nystudio107/webpack-dev-base" |
| 12 | + docker_image_tag: "latest" |
| 13 | + execute_commands: |
| 14 | + - "cd docker-config/webpack-dev-craft" |
| 15 | + - "npm ci" |
| 16 | + - "npm run build" |
| 17 | + volume_mappings: |
| 18 | + - "/:/buddy/$PROJECT_SHORTNAME" |
| 19 | + trigger_condition: "ALWAYS" |
| 20 | + shell: "BASH" |
| 21 | + - action: "Execute: composer install" |
| 22 | + type: "BUILD" |
| 23 | + working_directory: "/buddy/$PROJECT_SHORTNAME" |
| 24 | + docker_image_name: "nystudio107/php-dev-base" |
| 25 | + docker_image_tag: "latest" |
| 26 | + execute_commands: |
| 27 | + - "cd cms" |
| 28 | + - "composer install --no-scripts --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-reqs" |
| 29 | + setup_commands: |
| 30 | + - "echo \"memory_limit=-1\" >> /usr/local/etc/php/conf.d/buddy.ini" |
| 31 | + - "apt-get update && apt-get install -y git zip" |
| 32 | + - "curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer" |
| 33 | + - "# php ext pdo_mysql" |
| 34 | + - "docker-php-ext-install pdo_pgsql pgsql" |
| 35 | + volume_mappings: |
| 36 | + - "/:/buddy/$PROJECT_SHORTNAME" |
| 37 | + trigger_condition: "ALWAYS" |
| 38 | + shell: "BASH" |
| 39 | + - action: "Rsync files to production" |
| 40 | + type: "RSYNC" |
| 41 | + local_path: "cms/" |
| 42 | + remote_path: "$REMOTE_PROJECT_ROOT/deploy-cache" |
| 43 | + login: "$REMOTE_SSH_USER" |
| 44 | + host: "$REMOTE_SSH_HOST" |
| 45 | + port: "22" |
| 46 | + authentication_mode: "WORKSPACE_KEY" |
| 47 | + archive: true |
| 48 | + delete_extra_files: true |
| 49 | + recursive: true |
| 50 | + compress: true |
| 51 | + deployment_excludes: |
| 52 | + - "/.git/" |
| 53 | + trigger_condition: "ALWAYS" |
| 54 | + - action: "Atomic deploy" |
| 55 | + type: "SSH_COMMAND" |
| 56 | + working_directory: "$REMOTE_PROJECT_ROOT" |
| 57 | + login: "$REMOTE_SSH_USER" |
| 58 | + host: "$REMOTE_SSH_HOST" |
| 59 | + port: "22" |
| 60 | + authentication_mode: "WORKSPACE_KEY" |
| 61 | + commands: |
| 62 | + - "if [ -d \"releases/$BUDDY_EXECUTION_REVISION\" ] && [ \"$BUDDY_EXECUTION_REFRESH\" = \"true\" ];" |
| 63 | + - "then" |
| 64 | + - " echo \"Removing: releases/$BUDDY_EXECUTION_REVISION\"" |
| 65 | + - " rm -rf releases/$BUDDY_EXECUTION_REVISION;" |
| 66 | + - "fi" |
| 67 | + - "if [ ! -d \"releases/$BUDDY_EXECUTION_REVISION\" ];" |
| 68 | + - "then" |
| 69 | + - " echo \"Creating: releases/$BUDDY_EXECUTION_REVISION\"" |
| 70 | + - " cp -dR deploy-cache releases/$BUDDY_EXECUTION_REVISION;" |
| 71 | + - "fi" |
| 72 | + - "echo \"Creating: persistent directories\"" |
| 73 | + - "mkdir -p storage" |
| 74 | + - "echo \"Symlinking: persistent files & directories\"" |
| 75 | + - "ln -nfs $REMOTE_PROJECT_ROOT/.env $REMOTE_PROJECT_ROOT/releases/$BUDDY_EXECUTION_REVISION" |
| 76 | + - "ln -nfs $REMOTE_PROJECT_ROOT/storage $REMOTE_PROJECT_ROOT/releases/$BUDDY_EXECUTION_REVISION" |
| 77 | + - "ln -nfs $REMOTE_PROJECT_ROOT/transcoder $REMOTE_PROJECT_ROOT/releases/$BUDDY_EXECUTION_REVISION/web" |
| 78 | + - "echo \"Linking current to revision: $BUDDY_EXECUTION_REVISION\"" |
| 79 | + - "rm -f current" |
| 80 | + - "ln -s releases/$BUDDY_EXECUTION_REVISION current" |
| 81 | + - "echo \"Removing old releases\"" |
| 82 | + - "cd releases && ls -t | tail -n +11 | xargs rm -rf" |
| 83 | + trigger_condition: "ALWAYS" |
| 84 | + run_as_script: true |
| 85 | + shell: "BASH" |
| 86 | + - action: "Prep Craft CMS" |
| 87 | + type: "SSH_COMMAND" |
| 88 | + working_directory: "$REMOTE_PROJECT_ROOT/current" |
| 89 | + login: "$REMOTE_SSH_USER" |
| 90 | + host: "$REMOTE_SSH_HOST" |
| 91 | + port: "22" |
| 92 | + authentication_mode: "WORKSPACE_KEY" |
| 93 | + commands: |
| 94 | + - "# Ensure the craft script is executable" |
| 95 | + - "chmod a+x craft" |
| 96 | + - "# Restart our long running queue listener process" |
| 97 | + - "echo \"\" | sudo -S supervisorctl restart all" |
| 98 | + - "# Backup the database just in case any migrations or Project Config changes have issues" |
| 99 | + - "./craft backup/db" |
| 100 | + - "# Run pending migrations, sync project config, and clear caches" |
| 101 | + - "./craft migrate/all" |
| 102 | + - "./craft project-config/sync" |
| 103 | + - "./craft clear-caches/all" |
| 104 | + trigger_condition: "ALWAYS" |
| 105 | + run_as_script: true |
| 106 | + shell: "BASH" |
| 107 | + - action: "Send notification to nystudio107 channel" |
| 108 | + type: "SLACK" |
| 109 | + content: "[#$BUDDY_EXECUTION_ID] $BUDDY_EXECUTION_REVISION_SUBJECT - $BUDDY_EXECUTION_REVISION_COMMITTER_NAME" |
| 110 | + blocks: "[{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Successful execution:* <$BUDDY_EXECUTION_URL|Execution #$BUDDY_EXECUTION_ID $BUDDY_EXECUTION_COMMENT>\"},{\"type\":\"mrkdwn\",\"text\":\"*Pipeline:* <$BUDDY_PIPELINE_URL|$BUDDY_PIPELINE_NAME>\"},{\"type\":\"mrkdwn\",\"text\":\"*Branch:* $BUDDY_EXECUTION_BRANCH\"},{\"type\":\"mrkdwn\",\"text\":\"*Project:* <$BUDDY_PROJECT_URL|$BUDDY_PROJECT_NAME>\"}]}]" |
| 111 | + channel: "G6AKRT78V" |
| 112 | + channel_name: "nystudio107" |
| 113 | + trigger_condition: "ALWAYS" |
| 114 | + integration_hash: "5ef0d26820cfeb531cb10738" |
| 115 | + - action: "Send notification to nystudio107 channel" |
| 116 | + type: "SLACK" |
| 117 | + trigger_time: "ON_FAILURE" |
| 118 | + content: "[#$BUDDY_EXECUTION_ID] $BUDDY_EXECUTION_REVISION_SUBJECT - $BUDDY_EXECUTION_REVISION_COMMITTER_NAME" |
| 119 | + blocks: "[{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Failed execution:* <$BUDDY_EXECUTION_URL|Execution #$BUDDY_EXECUTION_ID $BUDDY_EXECUTION_COMMENT>\"},{\"type\":\"mrkdwn\",\"text\":\"*Pipeline:* <$BUDDY_PIPELINE_URL|$BUDDY_PIPELINE_NAME>\"},{\"type\":\"mrkdwn\",\"text\":\"*Branch:* $BUDDY_EXECUTION_BRANCH\"},{\"type\":\"mrkdwn\",\"text\":\"*Project:* <$BUDDY_PROJECT_URL|$BUDDY_PROJECT_NAME>\"}]}]" |
| 120 | + channel: "G6AKRT78V" |
| 121 | + channel_name: "nystudio107" |
| 122 | + trigger_condition: "ALWAYS" |
| 123 | + integration_hash: "5ef0d26820cfeb531cb10738" |
| 124 | + variables: |
| 125 | + - key: "PROJECT_SHORTNAME" |
| 126 | + value: "CHANGEME" |
| 127 | + - key: "PROJECT_URL" |
| 128 | + value: "https://CHANGEME.com" |
| 129 | + - key: "REMOTE_PROJECT_ROOT" |
| 130 | + value: "/home/forge/CHANGEME" |
| 131 | + - key: "REMOTE_SSH_HOST" |
| 132 | + value: "CHANGEME.com" |
| 133 | + - key: "REMOTE_SSH_USER" |
| 134 | + value: "forge" |
0 commit comments