Marbella, Spain
(34) 623041815
(10am - 05 pm)

Git based code deployment on Big Scoots


Many of our food blogger clients are hosted with Big Scoots, a popular managed WordPress host.

Their portal includes one-click push between your production and staging environments, which is great for testing code changes before deploying on your production site.

With a bit of work you can create a git-based deployment workflow similar to WPEngine. I’ve also written a similar article for using git with SpinupWP.

If everything below looks too technical, I highly recommend using the WP Pusher plugin. It’s incredibly easy to use, free for public repos, and reasonably priced for private repos. We use WP Pusher for any clients not hosted with Big Scoots or WPEngine.

Setting up git for production

Open a support ticket requesting ssh access to your server and include your public key. They will respond back confirming it has been set up and provide your ssh details (server, port, user).

Open Terminal and use ssh to connect to your server (ssh -p2222 [email protected]). We’ll follow this guide to setting up git on the server.

We’re going to set up a bare git repository in the site directory. We want to create it in clientname.com , not clientname.com/public.

By keeping it outside the public directory we won’t have any issues with the “Push Live to Staging” or “Push Staging to Live” features – they move the contents of the public directory.

  1. Navigate to the site directory. If the website is clientname.com, type cd domains/clientname.com
  2. Create a bare repository. git init --bare project.git
  3. Create the post-receive hook. touch project.git/hooks/post-receive
  4. Add execute permissions to the post-receive hook. chmod +x project.git/hooks/post-receive
  5. Edit the post-receive hook (vi project.git/hooks/post-receive) and add the following to it. Make sure you update the two paths at the top to match your environment

while read oldrev newrev ref
        # only checking out the master (or whatever branch you would like to deploy)
        if [ "$ref" = "refs/heads/$BRANCH" ];
                echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
                git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH
                echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
  1. Add the remote repository to your local environment
cd ~/path/to/working-copy
git remote add production ssh://[email protected]:2222/~/domains/clientname.com/project.git
  1. Push code to the production server git push production master

Setting up git for staging

You can use the exact same approach outlined above to setup git on staging.

If you haven’t created a staging environment yet, log into the BigScoots Portal, go to your site, and click “Create Staging”.

Once the staging site has been created, ssh into the server and navigate to the staging site’s directory. Using the clientname.com example above, the staging environment would be named clientnamecom.bigscoots-staging.com

Once you have everything setup on the server, go back to your local environment and add the staging remote

git remote add staging ssh://[email protected]:2222/~/domains/clientnamecom.bigscoots-staging.com/project.git


Source link

Leave A Reply