skip to navigation
skip to content

Not Logged In

git_deploy 0.3.0dev-20140209

Tool to manage using git as a deployment management tool

git-deploy
==========

It is a tool to manage using git as a deployment management tool implemented in Python and utilizing the dulwich [1]
project for native git functionality in Python.

Git-deploy implements the front end of the deployment system while hooks give the user flexibility in the lower level
details of the deploy. This client uses git to manage the state of your repository and deployment and assumes that on
sync the hooks ensure that the target is made consistent with the client (see default.sync) however, the user is free to
add their own deployment flow and environment options (see examples below).

[1] https://github.com/jelmer/dulwich


Usage
-----

Basic usage involves cloning the remote working repo to the deploy target and all client nodes. When
a client is ready to deploy 'start' is invoked to obtain a lock on the remote and 'sync' is called to
push changes to the target. On completion the lock is removed.

To start a new deployment, navigate to the working repo, issue a 'start' command:

$ git deploy start [opts]

At this point you are free to make commits to the project and when ready for deployment issue
a 'sync' command - or simply 'sync' if you're work is already complete but, be sure to rebase
your local clone:

$ git deploy sync [opts]

The process may be aborted at any point with an 'abort' command:

$ git deploy abort [opts]

You can rollback to a tag with the revert call:

$ git deploy revert [-t <tag_name>] [opts]

If no tag is supplied the rollback uses the most recent tag. The default is to only commit the rollback locally
however, by suppling the "-a" option for auto-sync the rollback automatically syncs also:

$ git deploy revert [-t <tag_name>] [opts]


Setup
-----

The following example illustrates how git-deploy can be configured and used for a single client and target. For this
example the client host and target host will be referred to as *client.realm.org* and *target.realm.org* respectively.
The home path on the client and target for our sample project is */home/me/project/* and */var/www/html/sample.com/*
respectively. It is assumed that the git remote is configured for your project and for this example the remote alias is
*origin* and the remote branch is *master*.


**CLIENT SETUP**

The client is any working machine from which deployments may be initiated. On *client.realm.org* clone git deploy, local
install, configure settings and initialize:

$ git clone git@github.com:Git-Tools/git-deploy.git

...

$ cd git-deploy
$ sudo pip install -e .

...

Next configure the client instance with git config by assigning the following settings in *scripts/git-deploy.ini*:

[deploy]
target=target.realm.org
path=/home/me/project/
user=me
hook-dir=.git/deploy/hooks/
tag-prefix=sample.com
remote=origin
branch=master
client-path=/home/me/project/
key-path=/home/me/.ssh/id_rsa
test-repo-path=/tmp/test_repo/
[system]
run_root=/usr/bin/

Once you have defined settings in *git-deploy.ini* call *init.py* to set the got config

$ sudo ./scripts/init_gd


**TARGET SETUP**

On *target.realm.org* there is no need to clone and install git-deploy but here the deploy hooks will need to be
created. There is a default hook in *git-deploy/default-hooks/default-target-pull.py* that should be copied to
*target.realm.org:/var/www/html/sample.com/.git/deploy/hooks/* This is a basic hook that will pull the changes
pushed from the client instance on sync.


**USING GIT DEPLOY**

First initialize a new repository on your client:

$ mkdir me.com
$ cd me.com
$ git init
$ git remote add origin git@github.com:wikimedia/me.com.git
$ git push origin master

On the target you only need to ensure that *path* in config exists and is configured as a git repo for your project.

*Start* & *Sync*:

Ensure that the client is correctly synced to the remote by issuing a git pull or rebase. Then you can issue a
a start command to write the lock file to the target to begin the deployment.

$ cd me.com
$ touch new_file
$ git add new_file
$ git commit -m "add - my new file"
$ git pull --rebase origin master

At this point you are ready to enter the deployment process:

client.realm.org:me.com me$ git deploy start

<perform any="" testing="" or="" add="" any="" other="" commits="" as="" necessary="" you've="" locked="" the="" remote="" at="" this="" point="">

client.realm.org:me.com me$ git deploy sync

Once you sync a the specified hooks will be invoked from the client and the target and a tag is written to the
repository on the latest commit of the deploy. If the default push and pull hooks are used the client will simply
push its changes to the remote and the target will pull in the new changes. Deployment tags have the form
*<repo>-sync-<date>-  
File Type Py Version Uploaded on Size
git_deploy-0.3.0dev-20140209.tar.gz (md5) Source 2014-02-09 23KB
  • Downloads (All Versions):
  • 2 downloads in the last day
  • 18 downloads in the last week
  • 35 downloads in the last month