Skip to content

Commit 6ef1fff

Browse files
authored
Create deploy.sh
1 parent 0382ec2 commit 6ef1fff

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

deploy.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Make sure this file has executable permissions, run `chmod +x deploy.sh` to ensure it does
4+
5+
# Variable name to check maintenance mode
6+
ENV_VAR_NAME="MAINTENANCE_MODE"
7+
8+
# Check if the environment variable is set to "true"
9+
if [[ "${!ENV_VAR_NAME}" = "true" ]]; then
10+
echo "Entering maintenance mode..."
11+
php artisan down
12+
fi
13+
14+
# Clear cache
15+
php artisan optimize:clear
16+
17+
# Cache the various components of the Laravel application
18+
php artisan config:cache
19+
php artisan event:cache
20+
php artisan route:cache
21+
php artisan view:cache
22+
23+
# Run any database migrations
24+
php artisan migrate --force
25+
26+
# Check if the environment variable is set to "false" or not set at all
27+
if [[ "${!ENV_VAR_NAME}" = "false" ]] || [[ -z "${!ENV_VAR_NAME}" ]]; then
28+
echo "Exiting maintenance mode..."
29+
php artisan up
30+
fi

0 commit comments

Comments
 (0)