domenica 20 novembre 2016

Bitbucket or Github + Hostmonster + MAMP auto deployment and clone

In OSX termina type in:

xcode-select --install
cd /Applications/MAMP/htdocs/
git init
git remote add origin ssh://git@bitbucket.org/musicstat/musicstat.git

Once you created your local files and put in your MAMP folder, login in Bitbucket and add your OSX ssh key for your user:
  • check that your ssh agent is running ps -e | grep [s]sh-agent
  • if not, start it ssh-agent /bin/bash
  • show your ssh key cat ~/.ssh/id_rsa.pub
  • if empty, you don't have a default key and need to generate it ssh-keygen
  • on OSX, copy the key into the clipboard pbcopy < ~/.ssh/id_rsa.pub
  • go to https://bitbucket.org/account/user/youruser -> SECURITY ssh keys
  • paste and don't remove anything, a mail will be sent by Bitbucket

git add --all


git commit -m 'initial comment'

git push -u origin master



This allows to have a local MAMP repository and a remote Bitbucket repository. Hostmonster should autoalign deploying from Bitbucket: as soon as you commit your local branch, Bitbucket updates and will update Hostmonster accordingly.

For the Hostmonster part, download the files here and upload in your website (/deploy folder):

https://bitbucket.org/lilliputten/automatic-bitbucket-deploy/src

Connect to your ssh Hostmonster hosting, go to the folder to be aligned:

pwd returns a full path e.g. 

/home2/youruser/public_html/yourwebsite/test

This path is the one to write in test/deploy/deploy-config.php
Once done, you need to setup www.yourwebsite.com/test/deploy as a "webhook" url inside Bitbucket: once BB receives a commit for new code from your local MAMP repo, visits the URL on your website, which will automatically git clone the new code:
  • Go to Bitbucket SERVICES (bottom menu item) -> Webhooks -> Add Webhook
  • fill in details, as default the action is bound on trigger "repository push", but you can also specify additional ones
The path would be like this: yourwebsite/test/deploy/bitbucket.php
or yourwebsite/test/deploy/github.php

The next time you will change something inside MAMP, you just go in MAMP folder and then

git add -A && git commit -m "modifications comment" && git push -u origin master

Nessun commento:

Posta un commento