Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A script for rapid deployment to FTP servers
Python CSS
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
deploy
docs
.gitattributes
.gitignore
LICENSE.md
README.md
deploy.cfg
pavement.py
paver-minilib.zip
setup.py

README.md

pyGitDeploy

A script for rapid deployment to FTP servers. The script uses git to find changes since last deployment and applies the changes to an FTP server, if no previous deployment has been made it uploads all watched files.

Rationale

Most shared hosting environments dont allow ssh, let alone git. To make sure all relevant changes are uploaded when your project reaches its next iteration this script runs a diff between your last deployment and current HEAD then syncs those changes with an FTP server.

New in version:

0.7.2

  • Change the way last deployment is saved, it is now saved in a file named lastDeploy on the server

Requirements:

Installation:

Clone the repo from github, then

paver install

Or

python setup.py install

Usage:

Assuming python and this script is in your path:

git deploy

The script will prompt you for ftp details and start the deployment process.

Advanced:

git deploy [-v <level>| --verbose <level>] [-n | --dry-run] <target>
  • --dry-run

    -n

    Runs the script without making any remote changes, only saves configuration and tells you what it would have done

  • --verbose

    -v

    Runs in verbose mode, the optional parameter specifies how verbose it should be, 0-5

Target is a named target server, the config file will keep track of individual targets and deployments

Config files

The config file is named deploy.cfg and is a standard ini-format file

Sections

The [global] section holds options valid for all remotes.

The [ftp] section and its siblings [ftp:<target>] represents individual deploy targets.

A sample config file has been provided.

global.ignore

Sample:

[global]
ignore = ["file1","file2","*.glob"]

Explanation

The ignore option must be placed in the global section and is a json array with each item representing a Glob pattern.

Ignored files are not uploaded

target.target_specific_files

Sample:

[ftp:target]
target_specific_files = {"config.ini":"config_online.ini",".htaccess",".htaccess_online"}

Explanation

The target_specific_files must be placed in a target section and takes the form of a json object. When looking at individual key : value pairs the key will be deleted online and value will take its place

Tested environments:

Windows versions:

  • Windows 7
  • Windows 8
  • Windows 8.1

Linux versions:

  • Mint 11-12
  • Ubuntu 10-14

Python versions:

  • 2.7.1-2.7.6

If you have used this script anywhere else with success feel free to send me a message and I will update this document.

Todo for version 1:

  • Add --revert to quickly go back to last deployment
  • Verbosity levels (work in progress)
  • Document command line options

Thanks:

Adeodato Simó for raw_input with editable default

Changelog:

0.7.1

  • Bugfix, checking for filesize when uploading a replacement file would trigger an exception. We now use that exception instead of filesize

0.7.0

  • Config now has a target specific option called target_specific_files, see the section on config files for details target_specific_files are provided instead of the proposed target specific branches.

0.6.2

  • Ignored files can now be a standard Glob pattern

0.6.1

  • Deploying using a diff from a specific commit was not as useful as hoped, instead you can supply a named target
  • Config has been moved outside of the git folder and into the repo root
  • Config now has a global section
    • Global section has an ignore option, this takes the form of a list of files to ignore for upload

0.6

  • Major rewrite, now uses Paver
  • Documentation overhaul in the works using Pycco

0.5.6

  • Now handles submodules

0.5.5.4

  • Fix bug #4 "Crashes when not run from repo root"

0.5.1 - 0.5.5.3

  • Default/previous values should now be presented correctly.
  • Fixed an issue with binary files, all files are now treated as binary.
  • Fixed a bloody stupid mistake when retrieving the hex of the current HEAD
  • Now actually deletes the files
  • Updated the way the script handles no previous commits (grabs all files with git ls-files)
  • Verbosity now a parameter
  • Added -n or --dry-run for a simulated run (no upload, no directories created remotely)
  • More verbosity
  • Made it possible to specify a specific state to deploy (in preperation for git deploy --revert)
  • Better format for default values
  • Retains previously input values as default (except for password)

0.5

  • Now actually saves remote information
Something went wrong with that request. Please try again.