Deploy web project under Git version control to shared hosting [closed]
Asked Answered
I

5

7

I am developing a WordPress theme which is under version control using Git and in a local development area ( WAMP ). I push commits to Bitbucket using smartgit as a GUI. I have 2 branches, master and development. I want to deploy the development branch to a staging area (a WordPress install on my live server).

I have tried using ftploy which does achieve this; however it doesn't seem to allow me to choose which branch to deploy and I want to reserve deployment of the master branch for the actual final deployment. I am using shared hosting but I have SSH access.

How can I best achieve deployment of the development branch to the shared hosting? Git is not installed on the server (and can't be).

Ivett answered 20/2, 2013 at 0:34 Comment(2)
is git installed on the server?Scapegrace
no ... sorry forgot to mention ... will update questionIvett
P
7

There is an article that suggest 7 apps for Git auto-deploy:

Preemption answered 20/9, 2015 at 20:30 Comment(0)
S
7

have a look at git-ftp:

I use git-ftp for my script based projects, mostly PHP. Most of the low-cost web hosting companies do not provide SSH or git support, but only FTP.

That is why I needed an easy way to deploy my git tracked projects. Instead of transfering the whole project, I thought, why not only transfer the files that changed since the last time, git can tell me those files.

Even if you are playing with different branches, git-ftp knows which files are different. No ordinary FTP client can do that.

Scapegrace answered 20/2, 2013 at 0:38 Comment(4)
Thanks. Actually I was really hoping for something automatic though. The whole point is that as I discover any bugs in the staging area (mainly I'm doing this to for w3c validation) I could make changes locally and push to the server. I think with git-ftp I have to type some commands into the prompt, along with the commit and push, and coupled with the fact that I'm already not particularly happy in cmd it's not my 'ideal' workflow; but I will use it if I have to. Do you think this is the best option I am likely to get? I suppose I wonder why a program like smartgit cant just deploy to ftp?Ivett
You can write git post-commit and post-merge hooks to run git-ftp on commit and merge. You can target specific branches only if that's your desired behavior.Autunite
@JonathanPatt If I wrote those then would I have to do anything special to get them to work when I did commit or merges via the Smartgit GUI?Ivett
No, if you set up hooks in git, all Uis will use them.Scapegrace
P
7

There is an article that suggest 7 apps for Git auto-deploy:

Preemption answered 20/9, 2015 at 20:30 Comment(0)
P
4

I'm the founder of FTPloy and I just wanted to let you know that we've now released the branch selection functionality.

Pervert answered 13/6, 2013 at 20:57 Comment(0)
I
1

Ended up using this script which does exactly what I want. Actually it was written by the same guy who built ftploy but because I had access to the script I was able to determine which branch got deployed. By the way I discovered that the ftploy roadmap includes being able to Select Branch for Bitbucket projects.

Ivett answered 20/2, 2013 at 3:5 Comment(5)
Beware! This looks like it will break heavily when you push more than one commit at once. I would strongly recommend following Jonathan’s advice and writing a post-commit hook for git-ftp.Scapegrace
@Scapegrace Thanks for the warning ... what makes you think this though?Ivett
The script only looks at the changes from the last commit – ever (see: commits[0]). Once you have pushed multiple commits your ftp will get out of sync and never return to a correct state again.Scapegrace
good to know, thanks ... I am going to look into the git-ftp and git hooks like advised.Ivett
To be fair I suppose the guy is recommending that it not be used at the top of the page anyway and to use ftploy instead.Ivett
P
0

Since you have SSH access, it would seem to me you could set up a rsync command in the git post-receive hook script. See https://github.com/EugeneKay/scripts/blob/master/bash/git-deploy-hook.sh I used this with gitolite but I am sure it is possible to do something similar with a github hook as well (anyone?)

Purifoy answered 31/5, 2013 at 23:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.