-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
53 lines (37 loc) · 1.09 KB
/
deploy.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
47
48
49
50
51
52
53
#!/bin/bash
RELEASE_DIRECTORY="./release"
# step 1 - create release folder
if [ -d "$RELEASE_DIRECTORY" ];
then
# Control will enter here if $DIRECTORY exists
echo "directory exists"
else
mkdir $RELEASE_DIRECTORY
echo "create directory"
fi
# step 2 - Clone repo and rename it for naming convention
cd $RELEASE_DIRECTORY
REPO_URL="https://[email protected]/edwinwong1990/weilibaocn-nuxt.git"
# naming convention e.g 2018-05-16-19-39-10
RELEASE_APP_FOLDER="$(date +'%Y-%m-%d-%H-%M-%S')"
# get the last segment of repo URL. e.g ../my-repo.git
REPO_NAME=${REPO_URL##*/}
# find .git extention for replace
FIND=".git"
REPLACE=""
# remove extention by replace it empty. e.g my-repo.git > my-repo
REPO_FOLDER_NAME=${REPO_NAME//$FIND/$REPLACE}
# git clone repo
sudo git clone $REPO_URL
# rename it to naming convention folder name
sudo mv $REPO_FOLDER_NAME $RELEASE_APP_FOLDER
# Step 3 - create symlink
cd ..
PWD=$(pwd)
PROJECT_PATH="$PWD/release/$RELEASE_APP_FOLDER"
if [ -L "current" ];
then
echo "symblink exist and deleting"
rm current
fi
ln -s $PROJECT_PATH current