update index.js, env

This commit is contained in:
Joseph Le 2023-10-13 13:21:50 +11:00
parent 148c52c103
commit fa09ae76bb
4 changed files with 15 additions and 27 deletions

View File

@ -5,7 +5,7 @@
### 1) Clone project to your server
```sh
git clone https://<USERNAME>:<PASSWORD>gitea.nswteam.net/joseph/gitea_CICD.git
git clone https://<USERNAME>:<PASSWORD>@gitea.nswteam.net/joseph/gitea_CICD.git
```
- Get username:
<div><img src="https://i.ibb.co/pLR2BjH/image.png" alt="getUsername" width="300"></div>

View File

@ -3,14 +3,19 @@ const express = require("express");
const app = express();
const { exec } = require("child_process");
const nodeMailer = require("nodemailer");
app.use(express.json());
app.post("/git/gitea-webhook", async (req, res) => {
const contentFile = await fs.readFileSync(
const contentFile = fs.readFileSync(
"./service_run/giteaService.conf",
"utf8"
);
const PORT = contentFile
.split("\n")
.filter((i) => i.includes("PORT_SERVICE"))[0]
?.split("=")[1]
.trim();
app.use(express.json());
app.post("/git/gitea-webhook", async (req, res) => {
const checkSendMail = contentFile
.split("\n")
.filter((i) => i.includes("SEND_EMAIL"))[0]
@ -75,7 +80,6 @@ app.post("/git/gitea-webhook", async (req, res) => {
});
});
const PORT = 5000;
app.listen(PORT, () => {
console.log("Server is running on port ", PORT);
});

View File

@ -38,24 +38,7 @@ function run_commands() {
echo ""
}
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]
") &&
result=$(spawn git pull origin $GIT_BRANCH) &&
echo "$result" &&
if [[ $result == *$fe_path* ]]; then
echo "|--------------------------------------------------------|"

View File

@ -4,10 +4,11 @@
HOOK_PATH=/home/gitea_CICD
# Git account (*)
GIT_USERNAME=<your_username>
GIT_PASSWORD=<your_password>
GIT_BRANCH=<your_branch>
# Port of server (*)
PORT_SERVICE=5000
# Email: Used to send notifications when the repository has updates (*)
EMAIL_ADDRESS=<youremail>
# Enable/Disable send mail: True or False (*)