udpate logic

This commit is contained in:
Joseph Le 2023-10-13 08:51:20 +00:00
parent 42d3a298ea
commit 52e19c07ff
4 changed files with 9 additions and 17 deletions

View File

@ -16,6 +16,7 @@ const PORT = contentFile
app.use(express.json());
app.post("/git/gitea-webhook", async (req, res) => {
console.log("AAAAAAAAAAAAAAAA")
const checkSendMail = contentFile
.split("\n")
.filter((i) => i.includes("SEND_EMAIL"))[0]

View File

@ -5,7 +5,6 @@ if [ -d "/etc/systemd/system" ]; then
echo -e "|***** \e[33mINSTALL SERVICE\e[0m *****|"
echo "|---------------------------|"
sleep 2 &&
pwd_install=$(pwd) &&
escaped_pwd_install=$(printf '%s\n' "$pwd_install" | sed -e 's/[\/&]/\\&/g') &&
echo ""
@ -15,29 +14,22 @@ if [ -d "/etc/systemd/system" ]; then
echo ""
find $pwd_install/service -type f -not -name "giteaService.conf" -exec cp {} $pwd_install/service_run \;
sleep 2 &&
sudo sed -i "s#ExecStart=.*#ExecStart=$escaped_pwd_install/service_run/giteaService.sh#" $pwd_install/service_run/giteaHook.service &&
echo -e "* \e[32mExecStart\e[0m *" &&
sleep 1 &&
sudo sed -i "s#WorkingDirectory=.*#WorkingDirectory=$escaped_pwd_install/service_run#" $pwd_install/service_run/giteaHook.service &&
echo -e "* \e[32mWorkingDirectory\e[0m *" &&
sleep 1 &&
sudo sed -i "s#EnvironmentFile=.*#EnvironmentFile=$escaped_pwd_install/service_run/giteaService.conf#" $pwd_install/service_run/giteaHook.service &&
echo -e "* \e[32mEnvironmentFile\e[0m *" &&
sleep 1 &&
sudo sed -i "s#HOOK_PATH=.*#HOOK_PATH=$escaped_pwd_install#" $pwd_install/service_run/giteaService.conf &&
echo -e "* \e[32mHOOK_PATH\e[0m *" &&
sleep 1 &&
sudo sed -i "s#source .*#source $escaped_pwd_install/service_run/giteaService.conf#" $pwd_install/service_run/giteaHook.sh &&
echo -e "* \e[32mEXEC_FILE\e[0m *" &&
echo ""
sleep 1 &&
sudo sed -i "s#source .*#source $escaped_pwd_install/service_run/giteaService.conf#" $pwd_install/service_run/giteaService.sh &&
@ -78,13 +70,11 @@ if [ -d "/etc/systemd/system" ]; then
echo "|----------------------|" &&
echo "" &&
systemctl enable giteaHook &&
sleep 2 &&
echo "|---------------------|" &&
echo -e "|*** \e[33mSTART SERVICE\e[0m ***|" &&
echo "|---------------------|" &&
echo "" &&
systemctl start giteaHook &&
sleep 2 &&
echo "|------------|" &&
echo -e "|*** \e[33mDONE\e[0m ***|" &&
echo "|------------|" &&

2
node_modules/.package-lock.json generated vendored
View File

@ -1,7 +1,7 @@
{
"name": "gitea_cicd",
"version": "1.0.0",
"lockfileVersion": 3,
"lockfileVersion": 2,
"requires": true,
"packages": {
"node_modules/abbrev": {

View File

@ -1,5 +1,6 @@
#!/bin/bash
source /home/phuc/gitea_CICD/service_run/giteaService.conf
export HOME=$PROJECT_PATH
# Đường dẫn tới tệp index.js
indexjs_path=$HOOK_PATH/index.js
project_path=$HOOK_PATH
@ -9,13 +10,13 @@ PASSWORD=$(echo "$GIT_PASSWORD" | sed 's/@/%40/g')
REPOSITORY_AUTH="https://$USERNAME:$PASSWORD@$(echo $GIT_REPOSITORY | sed 's#https://##')"
echo "$REPOSITORY_AUTH"
cd "$PROJECT_PATH" &&
git config --global --add safe.directory $PROJECT_PATH &&
git config --global --add safe.directory $HOME &&
SET_ORIGIN=$(git remote set-url origin $REPOSITORY_AUTH) &&
# Kiểm tra xem Node.js đã cài đặt chưa
# 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"
@ -27,7 +28,7 @@ else
node -v
fi
# Kiểm tra xem npm đã cài đặt chưa
# 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
@ -46,7 +47,7 @@ else
exit 1
fi
# Kiểm tra xem tệp index.js có tồn tại không
# 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" &&