git-deploy is a deployment tool to allow for quick and easy deployments based on the changes in a git repository.
It was originally used to update multiple WordPress installations on shared hosting environments. Ideally Capistrano would have been the perfect tool, but generally shared hosting environments only allow for FTP access, which Capistrano does not support. Likewise rather than using a standard FTP program, when doing a deployment, I only need to upload the files that have been changed. This saves me both time and bandwidth.
I needed something like Capistrano, but simpler.
git-deploy supports deployment over SSH and FTP.
git-deploy requires the Ruby gems net-ssh
, net-sftp
, net-scp
.
You can install them like so:
sudo gem install net-ssh net-sftp net-scp
Now install git-deploy; go to a new dir and:
$ git clone [email protected]:Juan-Facundo/git-deploy.git $ cd git-deploy $ sudo cp bin/git-deploy /usr/local/bin (ensure your $PATH)
In the root directory of your source code, create a deploy.yml
file.
Here is a sample code:
'ftp://example:[email protected]:21/path/to/installation': skip: false
You use the URI scheme to define the location of your installation. If you do not want to use the URI scheme, and instead use another identifier. Feel free to do so. Just enter the settings for the host like so:
'example': skip: false scheme: ftp user: example password: password host: example.com port: 21 path: /path/to/installation overwrite_if_same_revision: true
Note: The port field is optional in both the URI scheme and the broken down options
Once you have done creating the deploy.yml
, upload to your server a file called REVISION
with the revision string for the current revision residing on the server
After you have commited your code to the repository. You can run
git deploy
The configuration for a site has additional and optional options:
-
skip
:true
orfalse
(default). Whether to skip the configuration -
debug_mode
:true
orfalse
(default). For FTP only. Outputs debugging information -
passive
:true
orfalse
(default). For FTP only. Enable passive connection. -
local_path
: string. Only consider files to upload in a particular local path.
git-deploy
stores file called REVISION
on your server inside the root path to your application. This file stores the current revision of your application residing on your server.
When you run a git deploy
, git-deploy downloads the REVISION
file, and checks to see what files are different between revisions and either upload the changed files or deletes them from the server.
-
Create a Ruby gem for the script. Sadly
gem-deploy
was taken.
I have taken ‘git deploy` for my personal working and forked it. What i write below are personal experiences of working with this tool.
-
In some server “passive: true” is needed for correct working
-
Every time i used it, i needed to set password between quotes, just like the example below.
'settings': ignore_if_same_revision: true '/': skip: false scheme: ftp user: [email protected] password: 'password(quotes must remain)' host: your.host.com.ar port: 21 path: / passive: true local_path: website/