Giter Club home page Giter Club logo

deploy's Introduction

deploy

Minimalistic deployment shell script.

Installation

$ make install

Visit the wiki for additional usage information.

Usage

  Usage: deploy [options] <env> [command]

  Options:

    -C, --chdir <path>   change the working directory to <path>
    -c, --config <path>  set config path. defaults to ./deploy.conf
    -T, --no-tests       ignore test hook
    -V, --version        output program version
    -h, --help           output help information

  Commands:

    setup                run remote setup commands
    update               update deploy to the latest release
    revert [n]           revert to [n]th last deployment or 1
    config [key]         output config file or [key]
    curr[ent]            output current release commit
    prev[ious]           output previous release commit
    exec|run <cmd>       execute the given <cmd>
    console              open an ssh session to the host
    list                 list previous deploy commits
    [ref]                deploy to [ref], the 'ref' setting, or latest tag

Configuration

By default deploy(1) will look for ./deploy.conf, consisting of one or more environments, [stage], [production], etc, followed by directives.

[stage]
key /path/to/some.pem
user deployer
host n.n.n.n
port nn
repo [email protected]:visionmedia/express.git
path /var/www/myapp.com
ref origin/master
post-deploy /var/www/myapp.com/update.sh

Directives

key (optional)

Path to identity file used by ssh -i.

  key /path/to/some.pem

ref (optional)

When specified, HEAD is reset to ref. When deploying production typically this will not be used, as deploy(1) will utilize the most recent tag by default, however this is useful for a staging environment, as shown below where HEAD is updated and set to the develop branch.

    ref origin/develop

user

User for deployment.

   user deployer

host

Server hostname.

   host 50.17.255.50

port (optional)

Server port.

   port 22

repo

GIT repository to clone.

   repo [email protected]:visionmedia/express.git

path

Deployment path.

    path /var/www/myapp.com

forward-agent

Webhosts normally use read-only deploy keys to access private git repositories. If you'd rather use the credentials of the person invoking the deploy command, put forward-agent yes in the relevant config sections. Now the deploy script will invoke ssh -A when deploying and there's no need to keep SSH keys on your servers.

needs_tty

If your deployment scripts require any user interaction (which they shouldn't, but often do) you'll probably want SSH to allocate a tty for you. Put needs_tty yes in the config section if you'd like the deploy script to invoke ssh -t and ensure you have a tty available.

Hooks

All hooks are arbitrary commands, executed relative to path/current, aka the previous deployment for pre-deploy, and the new deployment for post-deploy. Of course you may specify absolute paths as well.

pre-deploy

  pre-deploy ./bin/something

post-deploy

  post-deploy ./bin/restart

test

Post-deployment test command after post-deploy. If this command fails, deploy(1) will attempt to revert to the previous deployment, ignoring tests (for now), as they are assumed to have run correctly.

  test ./something

License

(The MIT License)

Copyright (c) 2011 TJ Holowaychuk <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

deploy's People

Contributors

bronson avatar joaocc avatar jwyuen avatar necaris avatar paramaggarwal avatar singuerinc avatar tj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deploy's Issues

Config/Settings File

Sometimes I'll have a project that is open source where I need config or settings file that contains passwords, api keys, etc that I don't want to be in the git repo. It would be nice to have a field where deploy would push up that file in addition cloning the repo. Thoughts?

github deploy key

hello:
I'm a newer of github.I want to konw if github deploy key is necessary?

Directories badly created

Hi
After pm2 deploy setup, the directories seem to have been created badly:

ubuntu@ip-172-31-17-232:/srv/node/pse$ ls -l
total 8
lrwxrwxrwx  1 deploy deploy   20 Feb  1 23:52 current -> /srv/node/pse/source
drwxrwxr-x 10 deploy deploy 4096 Feb  1 23:52 source
drwxrwxr-x  3 deploy deploy 4096 Feb  1 23:52 {shared

ubuntu@ip-172-31-17-232:/srv/node/pse$ cd {shared
ubuntu@ip-172-31-17-232:/srv/node/pse/{shared$ ls
{logs,pids},source}

Any thoughts?
This is an ubuntu EC2 machine.

Thanks

Tilde expansion fails for ssh key value

I tried using tilde for my ssh key path. But that fails to find the key. I ensured that the path was correct. But, when I replaced the tilde with user homedir path, it worked fine.
Is the tilde expansion disabled or does it expand to root path? I did execute the script as own user. And there's the ssh key in that user's path.

SHARED env variable in post-deploy hook is blank

Hey, I'm trying to use a little hook magic for my node server, something like this:

post-deploy npm install && (cat $SHARED/pids/master.pid | xargs kill -s SIGUSR2) || PORT=8001 node server.js >> $SHARED/logs/node.log 2>&1

and well, it fails because $SHARED is blank, so I tried this to confirm:

post-deploy env

which listed SHARED=/home/deploy/app/shared as expected, but trying this:

post-deploy cat $SHARED/pids/master.pid

fails with cat: /pids/master.pid: No such file or directory, in other words SHARED is blank...

am I using it wrong?

It's on ubuntu 10.4 (installed using the node knockout linode stack script )

Git diff

What am I doing wrong?

# deploy stage
usage: git diff [--no-index] <path> <path>

  commit or stash your changes before deploying

more generic deployer

I'm trying to use this script to deploy Rails and Django applications but after looking at the source code I've encountered some specific rules like the creation of directories shared, logs, pids and source. It would be much better If you turn these rules into hooks in your environment. What do you think?

By the way, here's the diff file of my deploy script.

git for-each-ref fails in zsh

Hello,

The execution of for-each-ref fails when the target machine uses zsh (or csh) as its default shell.

deploy.conf

[production]
user joe
host localhost
repo [email protected]:jwhitfieldseed/deploy-test.git
path /tmp/deploy-test/production

Output from deploy where the target machine uses zsh:

~/code/deploy-test develop  
❯ deploy production
  ○ deploying
  ○ hook pre-deploy
  ○ fetching updates
Fetching origin
From github.com:jwhitfieldseed/deploy-test
   c8a0d31..88cb561  master     -> origin/master
   b7a1fb2..f404710  develop    -> origin/develop
 * [new tag]         moose4     -> moose4
From github.com:jwhitfieldseed/deploy-test
 * [new tag]         moose      -> moose
 * [new tag]         moose2     -> moose2
 * [new tag]         moose3     -> moose3
  ○ fetching latest tag
zsh:1: no matches found: --sort=-*authordate
  ○ resetting HEAD to
HEAD is now at c8a0d31 Merge branches 'develop' and 'master' of github.com:jwhitfieldseed/deploy-test
  ○ hook post-deploy
  ○ hook test
  ○ successfully deployed

Output of running that command in isolation on each of the shells on my machine (running Mavericks):

❯ zsh

~/code/deploy-test develop  
❯ git for-each-ref refs/tags \ 
      --sort=-*authordate \
      --format='%(refname)' \
      --count=1 | cut -d '/' -f 3
zsh: no matches found: --sort=-*authordate

~/code/deploy-test develop  

❯ bash
joe deploy-test $ git for-each-ref refs/tags \
>       --sort=-*authordate \
>       --format='%(refname)' \
>       --count=1 | cut -d '/' -f 3
moose4
joe deploy-test $ exit

~/code/deploy-test develop  
❯ sh
sh-3.2$ git for-each-ref refs/tags \
>       --sort=-*authordate \
>       --format='%(refname)' \
>       --count=1 | cut -d '/' -f 3
moose4
sh-3.2$ exit

~/code/deploy-test develop  
❯ ksh
$ 
me)' \
      --count=1 | cut -d '/' -f 3> 
me)' \
      --count=1 | cut -d '/' -f 3>       --format='%(refna
>       --count=1 | cut -d '/' -f 3
moose4
$ 

~/code/deploy-test develop  
❯ csh
[Joes-MacBook-Pro:~/code/deploy-test] joe% git for-each-ref refs/tags \
      --sort=-*authordate \
      --format='%(refname)' \
      --count=1 | cut -d '/' -f 3?       --sort=-*authordate \
?       --format='%(refname)' \
?       --count=1 | cut -d '/' -f 3
git: No match.

I don't know enough about the way each shell escapes newlines to have a quick fix (besides forcing bash on the target machine, which may not be so bad given that the deploy script itself is bash). Does anybody else have one? If not I am happy to look into it for a fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.