summaryrefslogtreecommitdiff
path: root/README.md
blob: c342c5cce89c919e69513575a9d062766dc2e71f (plain)
    1 ## Description
    2 
    3 **Git-deploy-cache** is a bash script intended to be called by a git
    4 post-receive hook. At execution time, it parses various information handed it
    5 by the git post-receive process (old ref, new ref, refname), and uses that
    6 information to clone the modified branch to a cache location for use by later
    7 scripts.
    8 
    9 A few ideas might be to use this script as a starting point to deploy app code,
   10 trigger test jobs, deploy a blog, manage a system (if you really wanted to).
   11 The posibilities are endless.
   12 
   13 
   14 ## Usage
   15 
   16 Usage of git-deploy-cache is simple. In the post-receive hook file of a bare
   17 git repository, simply source this script, providing a deployment base path as
   18 the first argument.
   19 
   20 For example, if you wanted all deployments to show up in ~/deploy/...
   21 
   22 __\<repo\>/hooks/post-receive__
   23 
   24     # Source the git-deploy-cache script here
   25     . ~/bin/git-deploy-cache ~/deploy/
   26 
   27 
   28 ### Arguments
   29 
   30 This script requires three arguments from STDIN: newrev, oldrev, and refname.
   31 These are the three variables passed to git post-receive hooks, which are
   32 passed by git on post-receive hook calls. It also requires one additional
   33 argument as the first argument: the base deploy path.
   34 
   35 
   36 ### Effect
   37 
   38 When this script deploys the given bare repo, it does so through two layers of
   39 directories: the repo name and the branch name. An example would be...
   40 
   41 From within the _foo_ repository, a push is issued to the master branch
   42 
   43     git push origin master
   44 
   45 From the deploy base, this directory structure will show up.
   46 
   47     <deploy-base>
   48     |
   49     `-> foo
   50         |
   51         `-> master
   52 
   53 If a deployment was done to the dev branch, the directory structure would now
   54 look like...
   55 
   56     <deploy-base>
   57     |
   58     `-> foo
   59         |
   60         `-> master
   61         |
   62         `-> dev
   63 
   64 
   65 ### Variables
   66 
   67 This script contains a function called **enviro_setup**. This function
   68 determines the values of several very useful variables and exports them so
   69 later scripts can use them without too much effort (let's face it, sometimes
   70 it's a pain having to rewrite commands to find a list of files changed in the
   71 given commit).
   72 
   73 The variables made available by this function are...
   74 
   75 * **REPOSITORY**: Repository that was pushed to
   76 * **BRANCH**: Name of the branch that was modified
   77 * **FILES_A**: List of **A**dded files
   78 * **FILES_M**: List of **M**odified files
   79 * **FILES_D**: List of **D**eleted files
   80 * **FILES_E**: List of all files **E**xisting in the commit, modified or new.
   81                Does not include deleted files.

Generated by cgit