Skip to content

Instantly share code, notes, and snippets.

@danprince
Created April 13, 2013 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danprince/5378153 to your computer and use it in GitHub Desktop.
Save danprince/5378153 to your computer and use it in GitHub Desktop.
GitHub deployment with prepare.py

Prepare

Reads the names of files that have arrived from a git pull and creates the necessary commands to deploy them in a deploy.sh file.

Usage

git pull | python prepare.py This creates a deploy.sh file sh deploy.sh Any new files will be deployed to the server.

Code

import sys 
import re 
 
f = open("deploy.sh", "w") 
for line in sys.stdin: 
        # Turn them into this "views/modes/profitiser.html" 
        matchObj = re.match( r'\s*(.*/)+(.*)\.(.*)\s*\|\s*\d+\s*\+*\-*', line) 
 
        if matchObj: 
                dir = matchObj.group(1) 
                file = matchObj.group(2) +"."+ matchObj.group(3) 
                command = "sudo cp " + dir + file + "/var/www/html/dev/sku/" + dir 
                f.write(command + "\n") 
f.close() 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment