update code

This commit is contained in:
joseph.le@apactech.io 2023-10-03 08:55:42 +00:00
parent 664ea5b48f
commit 945cfc7a9d
4 changed files with 0 additions and 134 deletions

3
.gitignore vendored
View File

@ -1,3 +0,0 @@
services
services/giteaService
text.txt

View File

@ -1,15 +0,0 @@
[Unit]
Description=Gitea Hook Service
After=network.target
[Service]
ExecStart=/home/joseph/gitea_CICD/service/giteaService.sh
Restart=always
WorkingDirectory=/home/joseph/gitea_CICD/service
User=root
Group=root
Restart=on-failure
EnvironmentFile=/home/joseph/gitea_CICD/service/giteaService
[Install]
WantedBy=multi-user.target

View File

@ -1,80 +0,0 @@
#!/bin/bash
#File chua bien moi truong
source /home/joseph/gitea_CICD/service/giteaService
#URL project
project=$PROJECT_PATH
#URL folder FE
fe_path=$(basename "$FE_PROJECT_PATH")
#URL folder BE
be_path=$BE_PROJECT_PATH
#URL other folder
#other="..."
#Username git
username=$GIT_USERNAME
#Password git
password=$GIT_PASSWORD
#Git branch
branch=$GIT_BRANCH
cd $project
result=$(expect -c "
set timeout 10
spawn git pull origin $GIT_BRANCH
expect {
\"Username for *\" {
send \"$username\r\"
exp_continue
}
\"Password for *\" {
sleep 2
send \"$password\r\r\"
exp_continue
}
eof
}
catch wait result
exit [lindex \$result 3]
") &&
echo "$result" &&
if [[ $result == *$fe_path* ]]; then
echo "|--------------------------------------------------------|"
echo "|***** THERE ARE CHANGES INSIDE FOLDER $fe_path *****|"
echo "|--------------------------------------------------------|"
echo "|---------------|"
echo "|*** INSTALL ***|"
echo "|---------------|"
cd $project/$fe_path &&
npm install
echo "|-------------|"
echo "|*** BUILD ***|"
echo "|-------------|"
npm run build &&
cp -rf $project/$fe_path/build/* $FE_ROOT_FOLDER_PATH
fi
echo "|----------------------|"
echo "|*** UPDATE LIBRARY ***|"
echo "|----------------------|"
cd $be_path &&
npm install
sleep 10
echo "|------------|"
echo "|*** DONE ***|"
echo "|------------|"

View File

@ -1,36 +0,0 @@
#!/bin/bash
# Đường dẫn tới tệp index.js
indexjs_path=$HOOK_PATH/index.js
project_path=$HOOK_PATH
# Kiểm tra xem Node.js đã cài đặt chưa
if ! command -v node &> /dev/null; then
echo -e "\e[31mNode.js is not installed.\e[0m"
echo -e "\e[32mInstall Node.js...\e[0m"
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&
sudo apt-get install nodejs -y &&
node -v
else
echo -e "\e[32mNodejs is installed!\e[0m" &&
node -v
fi
# Kiểm tra xem npm đã cài đặt chưa
if ! command -v npm &> /dev/null; then
echo -e "\e[31mnpm is not installed. Install npm...\e[0m"
sudo apt-get install npm -y
else
echo -e "\e[32mnpm is installed!\e[0m" &&
npm -v
fi
# Kiểm tra xem tệp index.js có tồn tại không
if [ -f "$indexjs_path" ]; then
echo "Run file $indexjs_path..."
cd "$project_path" &&
npm install &&
node "$indexjs_path"
else
echo -e "\e[31mFile $indexjs_path not exists\e[0m"
fi