Skip to content

Instantly share code, notes, and snippets.

@tommyready
Last active January 10, 2018 01:47
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 tommyready/58a8638fd469623b7236d95adae66ca0 to your computer and use it in GitHub Desktop.
Save tommyready/58a8638fd469623b7236d95adae66ca0 to your computer and use it in GitHub Desktop.
Python Laravel Deployment Script
import git
import string
import os
from os import path
from git import *
from subprocess import call
class gitConnect():
def deploy(self):
repo= git.Repo()
print('Current Branch: ' + str(repo.active_branch))
o = repo.remotes.origin
o.refs
repo.heads.master.set_tracking_branch(o.refs.master)
print("fetching origin")
o.fetch()
if(repo.active_branch <> "master"):
print("checking out master branch")
repo.heads.master.checkout()
print("git pull master")
o.pull()
print("composer update")
call(["composer", "update"])
print("optimzing Laravel")
call(["php","artisan","optimize"])
print("caching Laravel config")
call(["php","artisan","config:cache"])
print("caching Laravel routes")
call(["php","artisan","route:cache"])
print("minifying JS and CSS")
call(["gulp","--production"])
if __name__ == '__main__':
g = gitConnect()
g.deploy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment