7

I'm managing my wordpress template in Bitbucket.

Each time I push the theme, I must log in my VPS server and pull the repo. I want to do it automatically.

I found a solution if I run git deamon myown. Do an automatic pull request after pushing to server

But I want to use Bitbucket because it works as a backup also.

I found a Document about bitbucket's hook, but I could't find how to do it. https://confluence.atlassian.com/display/BITBUCKET/Manage+Bitbucket+hooks

Could anyone show me a solution?

Community
  • 1
  • 1
ironsand
  • 14,329
  • 17
  • 83
  • 176

1 Answers1

6

I did a very basic tutorial on this:

this basic steps are:

  1. Create a Read-Only access to the Repository with a public-key pair.
  2. Add the public key as a deployment key to your repository (Repository -> Settings -> Deployment keys)
  3. Pull your Repository to your WebServer via SSH
  4. Change ownership of the git-folder (you pulled) to www-data (as this is the apache2 user)
  5. Create a public accessable php script that executed a git pull
  6. Place a POST-hook to your php-pull-script on your Server (Repository -> admin -> Hooks -> POST)

Cant find admin?
while you are on your repository (on bitbucket) its the gearwheel in the top right. Either click on it or type 'r' and then 'a'.

Basic PHP script to make the pull:

<?php
    $output = shell_exec('git pull');
    echo "<pre>$output</pre>";
?>

I had this running just to proof that it is possible. Improve it :)

How to create a deployment key (step 2): enter image description here

KeatsPeeks
  • 19,126
  • 5
  • 52
  • 83
Langusten Gustel
  • 10,917
  • 9
  • 46
  • 59