Automatic deployment script to facilitate deployment of a Node application to a production server after a successful build.
First it pulls in the successful build from git, and installs dependencies. Then
it takes a copy to the
releaseDir (defaults to
the diff to the
deployDir and finally restarts the app as specified in
restartService run-script in
The following options are required - also, every directory must exist! (this should probably be changed, so the directory simply is created if it doesn't exist).
Which branch to deploy. Should probably always be the branch containing the
successful build - e.g.
Which commit to deploy. To deploy the successfully build commit from Travis,
Directory containing the git repository.
Directory containing the app. Files in this directory will be changed to match the new release.
- Remember to create a deploy key and add to github.
- All directories must exist.
Using ssh with an
authorized_keys entry like(
travis pubkey gives you
the repository's public key):
command="deploy $SSH_ORIGINAL_COMMAND",no-port-forwarding,no-X11-forwarding,\no-agent-forwarding,no-pty ssh-rsa AAAA...==
Put the following in your
.travis.yml file - this should work for private
repository's build by travis-ci.com.
after_success:- ssh -o StrictHostKeyChecking=no [user@]hostname "deploy -b $TRAVIS_BRANCH -c $TRAVIS_COMMIT --repoDir <path> --deployDir <path>"