gin93r
gin93r

Reputation: 1593

GIT Workflow - with dev and staging environments

I'm a newbie to git and have been looking and some workflows. I found this and really like it but I do have some questions.

I've set up a post receive hook on the master that updates a production server with all of the latest changes, however, I'm wondering how to handle dev and/or staging environments.

Is there a way to update subdomains on the server (ie: dev.mydomain.com, staging.mydomain.com) based on branch changes without having to maintain multiple repos for one project? If I push and only the develop branch changed, it would be great to update dev.mydomain.com. If I'm pushing changes to release branches, staging.mydomain.com would ideally update.

Also - I'm not using github. We have this setup on our own CentOS server with WHM/CPanel if any of that matters.

Upvotes: 0

Views: 169

Answers (3)

Panade
Panade

Reputation: 289

Git itself only provides the Repository structure and how Developers work together. For different Stages you should add cloned Projects, because they are supposed to diverge. Maintaining them is an important task, you can simply do this by hand or Write some Bash scripts, or even some CLI Programms for that. Maybe the Panel you are using, does provide some API calls. GitLab for Example has an API to automaticly do this kind of Stuff.

After that, all that matters is Timing it with an Cron Job or an Interface. :)

Upvotes: 1

Greg Burghardt
Greg Burghardt

Reputation: 18783

I don't see why you cannot do this. You should be able to grab the name of the branch that was just pushed (Writing a git post-receive hook to deal with a specific branch) and then deploy from the shell script.

Upvotes: 2

Leon Weber
Leon Weber

Reputation: 793

One sane way to do it would be to clone the repository to the webdir of each of the subdomains, checkout the appropriate branches there, and configure your git hook to update these repositories whenever something is pushed.

Upvotes: 1

Related Questions