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.
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.
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.
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. :)