Skip to content

rwprodev/git-hook-deploy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

git-hook-deploy

This is a aimple setup for PHP server to automatically pull down your git repo.

The below scripts can be used a templates for you to get this setup on your own. At a minimum, you will want to change the variables in the scripts to reflect your environment.

deploy.php

You need to configure your git web hook to send a POST request to this PHP script whenever you push changes to a desired branch. All popular git service providors provide this functionality.

All this script does is verify that there is a POST request and then simply create a file.

The next step is to setup a cron job that runs the below shell script.

check-deploy-hook.sh

This shell script check for the existence of a deploy hook file. If one is found, then it will go into your websites git repo. It will then perform a git reset and git pull on your repo. The latest updates will then get pulled down to your server.

Ensure that permissions are set to 700.

I schedule this job to run every 5 mins via a cron job.

*/5 * * * * /home/username/bin/check-deploy-hook.sh

Notes on setting up git

When you setup git on your server, you will want to make sure that you setup deployment ssh keys with your remote git service. This will make sure that everything is more secure. Check with your git service (Bitbucket, GitHub, etc) on how to set these up.

About

Simple setup for PHP server to automatically pull down your git repo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 57.5%
  • PHP 42.5%