Skip to content

A simple bash script to deploy on production using Git hooks

License

Notifications You must be signed in to change notification settings

alwaysdata/autodeploy-git-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

alwaysdata Autodeploy Git Hook

A simple bash script to deploy on production using Git hooks.

This script simply checkout the last version of a given branch (e.g a production branch) to a working directory. It updates your files and ensure your website / service is properly updated.

Install

To get it working, create a bare repository on your remote server and place the post-receive hook script in its hooks directory:

$ git init --bare ~/project.git
$ curl -L -o ~/project.git/hooks/post-receive https://raw.githubusercontent.com/alwaysdata/autodeploy-git-hook/master/post-receive
$ chmod +x project.git/hooks/post-receive

Configure

The script embed some variables you need to define to get it working properly. They are declared at the top of the post-receive file, feel free to adapt them to your needs:

  • TARGET: the directory where the files need to be deployed
  • GIT_DIR: the current git bare repository path
  • BRANCH: the branch to deploy (default to production)

In case you want to restart your app after deploy, you need to fill:

  • RESTART: a boolean to enable restart (default to false)
  • API_KEY: your api key you can find in your profile section
  • ACCOUNT: the account name your site is associated to
  • PASSWORD: the account password your site is associated to
  • SITE_ID: the reference ID of your site you can find in your sites section
  • NPM_INSTALL_CHECK: a boolean to enable if your site is a Node.js site, and if you want to automatically run npm install if your package.json changed since the last push (default to false)

Use

In your local repository, simply define a new remote, then push your production (or the branch you set in config) to this remote:

$ cd project
$ git remote add deploy <account>@ssh-<account>.alwaysdata.net:~/project.git
$ git checkout production
$ git push deploy production

The script logs actions in your git terminal, so the Git push action will show you that your deploy is OK or not.

Contribute

Feel free to contribute to the project by opening pull-requests, or fill issues that will let us improve it. Thanks 🍻 !

LICENSE

Release under MIT LICENSE.

For more information, you can take a look at our blog post about how to deploy using Git Hooks.

About

A simple bash script to deploy on production using Git hooks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages