I want know wheather its possible to automatically push code to production server? I have my code repo in bitbucket (git) and cloned it into my localhost and my production server. Whenever I do changes, I push it from the localhost and then pull it from the production server. Production server runs on EC2 ubuntu.
We use Pipelines with our Drupal 7 sites. Every time we approve a pull request to master branch, it automatically deploys to staging (we use WHM cPanel) by running the Pipeline which
We also have a production branch for deploying automatically to live (so we don't accidentally deploy something live that is on master - it's a specific step to ensure we're only deploying good code to the live server). Same thing. Pull request from master to production and the Pipeline runs again, deploying to live.
You, of course, need to set up your SSH keys so the Pipeline has permissions to deploy files to the server/s.
This is what the bitbucket-pipelines.yml in the root of our Drupal 7 project looks like.
- make ci-setup
- make ci-pre-deploy DRUSH=DRUSH_REMOTE_STAGING
- make ci-deploy-staging
- make ci-post-deploy DRUSH=DRUSH_REMOTE_STAGING
- make ci-setup
- make ci-pre-deploy DRUSH=DRUSH_REMOTE_PRODUCTION
- make ci-deploy-production
- make ci-post-deploy DRUSH=DRUSH_REMOTE_PRODUCTION
This is what the Makefile in the root of our Drupal 7 project looks like.
DRUSH_REMOTE_STAGING=ssh $(USER)@$(STAGING_HOST) drush -r public_html
DRUSH_REMOTE_PRODUCTION=ssh $(USER)@$(PRODUCTION_HOST) drush8 -r public_html
mkdir -p ~/.ssh
cat deploy/known_hosts >> ~/.ssh/known_hosts
(umask 077 ; echo $$SSH_KEY | base64 --decode > ~/.ssh/id_rsa)
rsync -e 'ssh' -irKzl --delete --verbose --exclude-from="deploy/.deploy-ignore" "./" $(USER)@$(STAGING_HOST):public_html
rsync -e 'ssh' -irKzl --delete --verbose --exclude-from="deploy/.deploy-ignore" "./" $(USER)@$(PRODUCTION_HOST):public_html
if [[ -f sites/default/settings.php ]] ; then $($(DRUSH)) vset maintenance_mode 1; else echo "Nothing to do"; fi
if [[ -f sites/default/settings.php ]] ; then $($(DRUSH)) updb -y; else echo "Nothing to do"; fi
if [[ -f sites/default/settings.php ]] ; then $($(DRUSH)) vset maintenance_mode 0; else echo "Nothing to do"; fi
We also have a /deploy folder with a .deploy-ignore file...
Also in the /deploy folder, there is a known_hosts file with ssh keys in there.
One of our senior dev team set this up, and I don't know every in-and-out of our config (eg. the Docker image that does the deploying) so the above won't just be a copy-and-paste affair. But hopefully, it will point you in the right direction. At least you now know it can work with Drupal 7 (I'm still trying to figure out how to get it rocking with Drupal 8 and composer).
Here is a link to the Pipeline docks. Hopefully, this post and the docs will get you going.
Auto-deployment with Pipelines has been SUCH a time saver for our team.
As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs