Domanda

I have a development environment and I would like to create a sub-domain for each branch is created in the my Git project.

In other words, if my dev environment is testenv.com and I create a new branch called feature123, I would like to automatically create a sub-domain such as: feature123.testenv.com where the code for that branch gets updated on every commit done to that branch.

The server is a LAMP environment.

Does anyone know how to achieve that? Any tools that you know?

Thank you!

È stato utile?

Soluzione

I assume that "create new branch" means (as per comments) that push to publishing repository ('publishing to project') includes new branch.

I don't know any ready solution, but it is something that can be done by post-receive hook installed on publishing repository (on 'project'). Said hook gets on its standard input the information about successfully pushed (published) branches:

<old-value> SP <new-value> SP <ref-name> LF

When creating a new ref, <old-value> is 40 '0'.

So the update script would create new sub-domain (e.g. creating <branchname>.conf file if your web server supports automatic and automatically loaded multi-file configuration) for each line which begins with 40 '0' (which matches /^0{40}/ regexp). This script could also be used to update sub-domains, for each branch that were successfully pushed.

HTH

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top