-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
61 lines (46 loc) · 2.41 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
These are a few of my git-hooks.
If you have nice hooks that might be helpful, please write a mail ([email protected])
To activate serverside hooks:
1) adjust "hooks_path" in "custom_hook"-loader script
2) rename existing hooks with dot-scheme (e.g. update -> update.gitosis)
3) link custom_hook loader as update/pre-receive/...
4) activate the wished hooks via repo config (see example below)
Overview:
validation
Description: Validates given filetype
Type: pre-receive
Depends: php-cli, xmllint, ...
extension
Description: Checks for 'forbidden' extensions
Type: pre-receive
chainpush
Description: Does chainpush to other repos/hosts (e.g. github)
Type: post-receive
deploy
Description: deploy via git
Type: post-receive
Example config for hooks (put this in the repos config):
[hooks]
validation = xml, php
chainpush = [email protected]/simonschiele/awesome.git, [email protected]:awesome.git
extension = doc, xls
deploy = local@/var/www/project2, /etc/keys/[email protected]
####################################
About remote deploying
####################################
The deploy hooks rely on a configured remote host.
The actual deploy script is configures in the authorized_keys of your deploy user - on hook side only "echo -n" gets triggered.
Sadly, you can only bind one deploy to one key, so you will have to create a lot of deploy keys.
On the plus side, this will enhance seucurity of the deploy model. Anyway, think about clean permissions before start using auto
deploy.
If you are using git to deploy web projects, be carefull that git directory is blocked by apache or outside of htdocs.
My default setup on remote host:
* I create a passwordless user named "deploy"
* give him his home-dir as /var/cache/deploy
* create a ssh keypair for git pull
* put private key in /var/cache/deploy/.ssh/
* add public key with read permissions to gitlolite/gitosis
* create another key pair for actual deploy
* put private key on the server that triggers the git-hook
* add public key to /var/cache/deploy/.ssh/authorized_keys with something like this:
command="cd /srv/www/page1 && echo Deploying to $(pwd) on $(hostname) && git pull",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AA......... deploy@host