git-deploy icon indicating copy to clipboard operation
git-deploy copied to clipboard

there's no way to monitor 2 different branches of the same repo

Open aethernet opened this issue 10 years ago • 7 comments

ie : master & staging

aethernet avatar Dec 27 '13 21:12 aethernet

I also ran into this issue. Is there a quick way to change the code to accommodate this?

mattesser avatar Mar 09 '14 22:03 mattesser

I'd be curious to know the usecase/workflow for this when it comes to deployment. Are you talking about deploying two branches to two locations, or two branches to the same location and basically have it switch branches when you commit to one or the other?

In general for a staging site, I would recommend deploying a staging brach, doing development in feature branches, and when a feature is fully baked, merging just that feature into master to push it to production.

lkwdwrd avatar Mar 10 '14 04:03 lkwdwrd

For me the workflow would be this...

Two branches, develop and master.

If I work on my code, it is primarily in develop. Commit something, push it to Hit or Bitbucket and then run the post hook that calls this PHP script and works as advertised and places the code into a folder on my server that has both stage and production on it. I then use your script to run rsync to move the files into place. This part works great.

I then tried to add a different branch for the same project (master) and have it download to a different location and run rsync to move it to the production location but having two names the same in your array causes it to break. Could there be a way to define two different locations and two different post process scripts in your deploy script for the same project?

mattesser avatar Mar 10 '14 11:03 mattesser

I'll see if I can come up with a way to allow two branches for the same project to deploy to two locations. That does make sense, probably some kind of conflict with the way the config array is set up. I've got a quite a few things going on right now, so writing this may take me a little while to get to.

lkwdwrd avatar Mar 15 '14 20:03 lkwdwrd

I'd like to +1 this as well, I have a staging branch and a production branch. My staging site is a subdirectory of my production, so I have production in /var/www/html and staging in /var/www/html/staging. They use the same repo. I'm thinking instead of using a assoc array, you could just use an array of configs and have the repo name in that array.

francislavoie avatar Jun 09 '14 15:06 francislavoie

I've come up with a a fix for this. I've forked the repo and will be testing the fix over the next day or so.

Basically, the fix is twofold: "branch" in the config can optionally take an associative array of branch names and paths. If it is an array, and there's a match, then it uses the matching path.

The second part to the fix is letting the match be a bit lazy - so any branch that starts with what is given in the config will match. E.g. "branch" => "release/v1.1" will match "release/v1.1.1" as well... did this because I'm fine with Patch releases going to the same directory. Sometimes I'm even fine with minor versions and just want to keep different deploy configs for major versions...

https://github.com/jazzmind/git-deploy

jazzmind avatar Jun 23 '14 01:06 jazzmind

https://github.com/francislavoie/git-deploy

I made my own implementation as well, I instead modified it to use a "repo nickname" for the assoc array key, and the actual repo name is within the array. My implementation is only done for Bitbucket because I'm only using bitbucket for my current project.

It might be a little convoluted of a change, but it's what worked for me.

francislavoie avatar Jun 23 '14 02:06 francislavoie