-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpost-receive
61 lines (46 loc) · 993 Bytes
/
post-receive
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
61
#!/bin/sh
#BRANCH="main"
# Put absolute php path to use
PHP=php
# Put composer command to use if use different composer than default
COMPOSER=$(which composer)
DIFF=""
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ -z "$BRANCH" ]
then
DIFF="$DIFF `git diff --name-only $oldrev $newrev`"
else
if [ "$BRANCH" == "$branch" ]
then
DIFF="$DIFF `git diff --name-only $oldrev $newrev`"
fi
fi
done
if [ "$(git submodule)" != "" ]
then
git submodule update --remote --init
fi
cd $GIT_DIR/..
if [ -z $(command -v $PHP) ]
then
echo 'php not found'
exit 1
fi
if [ ! -f artisan ]
then
echo 'artisan not found'
exit 1
fi
$PHP artisan down
if [ "$(echo $DIFF | grep composer)" != "" ]
then
$PHP $COMPOSER install -o --no-dev --no-interaction
fi
if [ "$(echo $DIFF | grep migration)" != "" ]
then
$PHP artisan migrate --force
fi
$PHP artisan optimize
$PHP artisan up