Skip to content

michalsvec/git-deploy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

git-deploy

Description

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 FTP.

  • This fork comes with some changes for my workflow. I changed format of configuration file to be able to choose

upload directory on the same server as a parameter. It is very useful when one wants to test the implementation in directory with beta version of the system. In my case there is second subdomain with beta version.*

Installation

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

Usage

In the root directory of your source code, create a deploy.yml file.

Here is a sample code:

'settings':
  ignore_if_same_revision: true

'server1':
  skip: false
  scheme: ftp
  user: example
  password: password
  host: example.com
  port: 21
  path: /path/to/script

In this case script will use same path to script and there is no need for the second parameter with “git deploy”

In case of using beta testing directory, extend config like this:

'settings':
  ignore_if_same_revision: true

'server1':
  skip: false
  scheme: ftp
  user: example
  password: password
  host: example.com
  port: 21
  path: 
    default: /www/
    beta: /beta/
  ignore: [ignored/, deploy.yml, .htaccess]

Note: The port field is optional

Ignored files and directories are in form of array. If the file name contains string from ignored array, it is not uploaded. It can be in local repository, but won’t be uploaded to the server. Typical example of ignored file is deploy.yml

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

Using git-deploy

After you have commited your code to the repository. You can run

git deploy

for default remote directory or

git deploy beta

and the script will upload changes to /beta/ direcotiry on the server.

If you want to upload maintenance file before uploading changed files from git repository, set the maintenance_file and maintenance_deploy_to in configuration file.

You will also need to upload a REVISION file to your server inside the installation path, ie “/path/to/installation”

To create a REVISION file for HEAD, exexcute:

git rev-parse HEAD > REVISION

This will create a REVISION file which you will need to upload to your server

Additional Keys

The configuration for a site has additional and optional options:

  • skip: true or false (default). Whether to skip the configuration

  • debug_mode: true or false (default). For FTP only. Outputs debugging information

  • passive: true or false (default). For FTP only. Enable passive connection.

  • local_path: string. Only consider files to upload in a particular local path.

  • maintenance_file: string. Local path of maintenance file.

  • maintenance_deploy_to: string. Maintenance file path on remote server.

How It Works

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.

TODO

  • Automatically create REVISION on the server

About

Quick and easy deployment from git repository to FTP server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%