udpate logic
This commit is contained in:
parent
42d3a298ea
commit
52e19c07ff
1
index.js
1
index.js
|
|
@ -16,6 +16,7 @@ const PORT = contentFile
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
app.post("/git/gitea-webhook", async (req, res) => {
|
app.post("/git/gitea-webhook", async (req, res) => {
|
||||||
|
console.log("AAAAAAAAAAAAAAAA")
|
||||||
const checkSendMail = contentFile
|
const checkSendMail = contentFile
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.filter((i) => i.includes("SEND_EMAIL"))[0]
|
.filter((i) => i.includes("SEND_EMAIL"))[0]
|
||||||
|
|
|
||||||
10
install.sh
10
install.sh
|
|
@ -5,7 +5,6 @@ if [ -d "/etc/systemd/system" ]; then
|
||||||
echo -e "|***** \e[33mINSTALL SERVICE\e[0m *****|"
|
echo -e "|***** \e[33mINSTALL SERVICE\e[0m *****|"
|
||||||
echo "|---------------------------|"
|
echo "|---------------------------|"
|
||||||
|
|
||||||
sleep 2 &&
|
|
||||||
pwd_install=$(pwd) &&
|
pwd_install=$(pwd) &&
|
||||||
escaped_pwd_install=$(printf '%s\n' "$pwd_install" | sed -e 's/[\/&]/\\&/g') &&
|
escaped_pwd_install=$(printf '%s\n' "$pwd_install" | sed -e 's/[\/&]/\\&/g') &&
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -16,28 +15,21 @@ if [ -d "/etc/systemd/system" ]; then
|
||||||
|
|
||||||
find $pwd_install/service -type f -not -name "giteaService.conf" -exec cp {} $pwd_install/service_run \;
|
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 &&
|
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 *" &&
|
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 &&
|
sudo sed -i "s#WorkingDirectory=.*#WorkingDirectory=$escaped_pwd_install/service_run#" $pwd_install/service_run/giteaHook.service &&
|
||||||
echo -e "* \e[32mWorkingDirectory\e[0m *" &&
|
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 &&
|
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 *" &&
|
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 &&
|
sudo sed -i "s#HOOK_PATH=.*#HOOK_PATH=$escaped_pwd_install#" $pwd_install/service_run/giteaService.conf &&
|
||||||
echo -e "* \e[32mHOOK_PATH\e[0m *" &&
|
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 &&
|
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 -e "* \e[32mEXEC_FILE\e[0m *" &&
|
||||||
echo ""
|
echo ""
|
||||||
sleep 1 &&
|
|
||||||
|
|
||||||
sudo sed -i "s#source .*#source $escaped_pwd_install/service_run/giteaService.conf#" $pwd_install/service_run/giteaService.sh &&
|
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 "|----------------------|" &&
|
||||||
echo "" &&
|
echo "" &&
|
||||||
systemctl enable giteaHook &&
|
systemctl enable giteaHook &&
|
||||||
sleep 2 &&
|
|
||||||
echo "|---------------------|" &&
|
echo "|---------------------|" &&
|
||||||
echo -e "|*** \e[33mSTART SERVICE\e[0m ***|" &&
|
echo -e "|*** \e[33mSTART SERVICE\e[0m ***|" &&
|
||||||
echo "|---------------------|" &&
|
echo "|---------------------|" &&
|
||||||
echo "" &&
|
echo "" &&
|
||||||
systemctl start giteaHook &&
|
systemctl start giteaHook &&
|
||||||
sleep 2 &&
|
|
||||||
echo "|------------|" &&
|
echo "|------------|" &&
|
||||||
echo -e "|*** \e[33mDONE\e[0m ***|" &&
|
echo -e "|*** \e[33mDONE\e[0m ***|" &&
|
||||||
echo "|------------|" &&
|
echo "|------------|" &&
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "gitea_cicd",
|
"name": "gitea_cicd",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"node_modules/abbrev": {
|
"node_modules/abbrev": {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
source /home/phuc/gitea_CICD/service_run/giteaService.conf
|
source /home/phuc/gitea_CICD/service_run/giteaService.conf
|
||||||
|
export HOME=$PROJECT_PATH
|
||||||
# Đường dẫn tới tệp index.js
|
# Đường dẫn tới tệp index.js
|
||||||
indexjs_path=$HOOK_PATH/index.js
|
indexjs_path=$HOOK_PATH/index.js
|
||||||
project_path=$HOOK_PATH
|
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://##')"
|
REPOSITORY_AUTH="https://$USERNAME:$PASSWORD@$(echo $GIT_REPOSITORY | sed 's#https://##')"
|
||||||
|
|
||||||
echo "$REPOSITORY_AUTH"
|
|
||||||
|
|
||||||
cd "$PROJECT_PATH" &&
|
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) &&
|
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
|
if ! command -v node &> /dev/null; then
|
||||||
echo -e "\e[31mNode.js is not installed.\e[0m"
|
echo -e "\e[31mNode.js is not installed.\e[0m"
|
||||||
echo -e "\e[32mInstall Node.js...\e[0m"
|
echo -e "\e[32mInstall Node.js...\e[0m"
|
||||||
|
|
@ -27,7 +28,7 @@ else
|
||||||
node -v
|
node -v
|
||||||
fi
|
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
|
if ! command -v npm &> /dev/null; then
|
||||||
echo -e "\e[31mnpm is not installed. Install npm...\e[0m"
|
echo -e "\e[31mnpm is not installed. Install npm...\e[0m"
|
||||||
sudo apt-get install npm -y
|
sudo apt-get install npm -y
|
||||||
|
|
@ -46,7 +47,7 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
if [ -f "$indexjs_path" ]; then
|
||||||
echo "Run file $indexjs_path..."
|
echo "Run file $indexjs_path..."
|
||||||
cd "$project_path" &&
|
cd "$project_path" &&
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue