Deploy Sites via GitHub

Super simple way to develop locally and then deploy sites via GitHub.

This screencast was inspired by Mark Otto’s great post about this workflow. Implementing this workflow takes next to no time, is very easy to upkeep and is also secure for your files thanks to GitHub.

Running time: 9:14

Commands to Clone and Maintain

Once you have committed your code to GitHub you can follow these steps to quickly deploy.

$ ssh

Once connected, navigate to your domain and clone the repository in the desired location.

$ git clone [REPO_URL]

Once you have completed the above, all future updates just need to be done like so:

$ ssh

Once connected, navigate to your repository (make sure you are inside the repository!).

$ git pull origin master

Reload your live site.

Note: You might have to install Git on your server.

Happy deploying!

5 thoughts on “Deploy Sites via GitHub”

  1. You can set GitHub to automatically tell your website that a commit has been pushed to your repository. If you go into [Your Repo] -> Settings -> Service Hooks -> WebHook URLs and enter the url to a PHP file on your site, GitHub will make a POST request letting you know a push has been made.

    Here’s how I would do it.

    Create a “secret” PHP file at the root of your domain called update-theme.4b48af.php with the following content.

    // tell our shell script to update the theme

    Inside the shell script
    Note: you may need to call chmod +x to make it executable.

    # change to the theme directory and
    # pull the changes from GitHub
    cd ./wp-content/themes/wp-weekly-theme && git pull origin master

    The shell script is just a series of bash commands. I used the && so that the second command would only run if it changed to the proper directory.

    Also, I separated the bash commands from the PHP because it makes more since running bash commands from a shell script.

    PS: I’m not sure how the code will look in this comment, so I created a GitHub Gist to be careful:

    • Baylor!

      That is awesome, I didn’t realise how easy it is. I haven’t had time to set it up yet but will soon.

      BTW – You have some awesome vids on your YouTube channel. Keep them coming.

      Thanks again.

    • Oh thats pretty sweet Matt!

      I am sure it won’t be just me that will find that handy. Thanks for sharing.

  2. This is how we do it for ArcTap. We have a file in the root of the project called github.php which has the following contents…

    <?php `git pull`;

    This workflow was suggested from this article and is pretty easy to setup.

    There is also another method Paul Irish mentions in his talk at the HTML5DevConf and starts at 13:00.

Comments are closed.