forked from codeigniter4projects/website
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·58 lines (45 loc) · 1.4 KB
/
deploy.sh
File metadata and controls
executable file
·58 lines (45 loc) · 1.4 KB
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
#!/bin/sh -e
# Deploys the official site to the production server.
# See ../workflows/deploy.yml
REPO="/opt/website"
RELEASE_DIR="/home/public_html/site/releases"
SHARED_DIR="/home/public_html/site/shared"
USERGUIDE_DIR="/home/public_html/userguides"
CONFIG_FILE="/home/public_html/config/.env.site"
if [ "$(id -u)" = "0" ]; then
echo "Cannot be run as root. Please run as the user for deployment."
exit 1
fi
RELEASE=`date +"%Y-%m-%d-%H-%M-%S"`
echo 'Update website repository\n'
cd $REPO
git switch master
git pull
echo 'Copy current release\n'
cd $RELEASE_DIR
sudo cp -pr $REPO ./$RELEASE
echo 'Install composer dependencies\n'
cd $RELEASE_DIR/$RELEASE
composer install --no-dev
if [ ! -d "$SHARED_DIR" ]; then
echo 'Create shared directory\n'
sudo mkdir -p "$SHARED_DIR"
echo 'Setup folder permissions\n'
sudo chown -R www-data:www-data writable
sudo chmod -R 755 writable
sudo cp -rp writable "$SHARED_DIR"
fi
echo 'Link writable\n'
sudo rm -rf writable
sudo ln -nsf "$SHARED_DIR/writable" writable
echo 'Link .env\n'
sudo ln -nsf $CONFIG_FILE .env
echo 'Link user guides\n'
ln -nsf $USERGUIDE_DIR/userguide4 public/user_guide
ln -nsf $USERGUIDE_DIR/userguide3 public/userguide3
ln -nsf $USERGUIDE_DIR/userguide2 public/userguide2
echo 'Deploy: update symlink\n'
cd $RELEASE_DIR
sudo ln -nsf $RELEASE_DIR/$RELEASE "../current"
echo 'Reload PHP8.1-FPM\n'
sudo service php8.1-fpm reload