mayconfsbrito
mayconfsbrito

Reputation: 2413

How deploy my environment with git?

I've a environment to deploy with git and I don't know how do this. Our team works with several developers hosts (local repositories for each one) which should push for one server with the central repository. So we have other two servers with "bare" repositories for each one, but this two repositories are mirrors of the central repository and exists just for to update the project in the directories /var/www.

These two final servers are our web servers. The central server are our repository server, it should to update the webserver at moment who a developer push from your the developer machine for the central server.

I've already updated (pushed) from the dev machine directly to one web server with this post-receive hook.

#!/bin/sh
GIT_WORK_TREE=/var/www/project_name git checkout -f

But now, with this new scenario how I will make the central server to update the web servers? With post-receive? Or what?

Theoretically I want do something like this:

$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=ssh://user@webserver/var/www/project_name git checkout -f
$ chmod +x hooks/post-receive

Where GIT_WORK_TREE="ssh" is the webserver adress with ssh.

Upvotes: 1

Views: 151

Answers (1)

VonC
VonC

Reputation: 1324318

You could do a post-receive hook on your main central server in order to push to the bare repos of the web server.

That way, each post-receive hoook already in place on those bare web server repos would still run as they do right now.
But they would be trigger by an automatic push from the central server, instead of a direct push from a dev.

Upvotes: 1

Related Questions