-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeployeNEWCode.sh
46 lines (27 loc) · 768 Bytes
/
DeployeNEWCode.sh
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
#!/bin/bash
DEPLOY_DIR="/var/www/html" #code will be deployed here
GIT_REPO="https://github.com/kaverigojre/Building-CI-CD-Pipeline-Tool"
BRANCH="main" #git branch
#Nginx configuration file
NGINX_CONF="C:\Users\Kaver\Downloads\nginx\nginx-1.24.0\conf" #My Nginx conf file
updating_code()
{ #fuction to update the existing code
echo "Updating code from Git repo"
cd $DEPLOY_DIR || exit
git pull origin $BRANCH
}
restarting_nginx()
{
# Function to restart Nginx
echo "Restarting Nginx..."
sudo systemctl restart nginx
}
# updating the Git repository
if [ -d "$DEPLOY_DIR" ]; then
update_code
else
git clone -b $BRANCH $GIT_REPO $DEPLOY_DIR
fi
updating_code
restarting_nginx
echo "Deployment completed successfully!"