-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-receive
42 lines (30 loc) · 1.38 KB
/
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
#!/bin/bash
TARGET="/var/www/PROJECT_NAME"
GIT_DIR="/home/yehuda/repo/PROJECT_NAME.git"
BRANCH="master"
SLACK_POST_URL="https://hooks.slack.com/services/<YOUR-URL-HERE>"
while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
if [ "$ref" = "refs/heads/$BRANCH" ];
then
cd $TARGET
pwd
echo "activating maintenance mode"
php artisan down
echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH
echo "Running NPM build command"
npm install
npm run build
echo "running composer install"
composer install --no-interaction --no-dev --prefer-dist
echo "running migrations"
php artisan migrate --force
echo "going back live..."
php artisan up
curl -X POST --data-urlencode "payload={'channel': '#deployments', 'username': 'yiddishe-bot', 'text': 'Successfully deployed to <https://IP_ADDRESS/|PROJECT_NAME>!', 'icon_emoji': ':yiddishe-kop:'}" $SLACK_POST_URL
else
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
fi
done