Commit | Line | Data |
---|---|---|
c3733902 LMM |
1 | #!/bin/sh |
2 | # | |
3 | # An example hook script that is called after a successful | |
4 | # push is made. | |
5 | # | |
6 | ||
7 | echo "------- post-update started -------" | |
1b6e760d LMM |
8 | # Disabling this, we're moving to rsync because it works better. |
9 | #ssh www-data@ryf.fsf.org "cd /var/www/git;git pull" | |
10 | unset GIT_DIR | |
11 | SELF=ryf.git | |
12 | REPO_DIR=$HOME/repositories | |
13 | CHECKOUT_DIR=$HOME/local/checkouts/$SELF | |
14 | TARGET_DIR=/var/www/ryf.fsf.org | |
15 | TARGET_HOST=ryf.fsf.org | |
16 | ||
17 | ||
18 | case $1 in | |
19 | refs/heads/live) | |
20 | branch=live | |
21 | ;; | |
22 | refs/heads/dev) | |
23 | branch=dev | |
24 | ;; | |
25 | *) | |
26 | echo "No action for this branch!" | |
27 | ;; | |
28 | esac | |
29 | ||
30 | ||
31 | echo "Updating local checkout..." | |
32 | if [ ! -d $CHECKOUT_DIR ]; then | |
33 | git clone $REPO_DIR/$SELF $CHECKOUT_DIR | |
34 | cd $CHECKOUT_DIR | |
35 | git checkout $branch | |
36 | else | |
37 | cd $CHECKOUT_DIR | |
38 | git checkout $branch | |
39 | git pull origin $branch | |
40 | fi | |
41 | ||
42 | if [ -n $TARGET_HOST ]; then | |
43 | echo Deploying to: $branch | |
44 | rsync -avrSPX --delete-after $CHECKOUT_DIR/* root@$TARGET_HOST:$TARGET_DIR/ | |
45 | fi | |
46 | ||
47 | exec git update-server-info | |
c3733902 LMM |
48 | echo "------- post-update finished ------" |
49 |