forked from joseph/gitea_CICD
update index.js, env
This commit is contained in:
parent
148c52c103
commit
fa09ae76bb
|
|
@ -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>
|
||||
|
|
|
|||
14
index.js
14
index.js
|
|
@ -3,14 +3,19 @@ const express = require("express");
|
|||
const app = express();
|
||||
const { exec } = require("child_process");
|
||||
const nodeMailer = require("nodemailer");
|
||||
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 contentFile = await fs.readFileSync(
|
||||
"./service_run/giteaService.conf",
|
||||
"utf8"
|
||||
);
|
||||
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);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,25 +38,8 @@ 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]
|
||||
") &&
|
||||
echo "$result" &&
|
||||
result=$(spawn git pull origin $GIT_BRANCH) &&
|
||||
echo "$result" &&
|
||||
if [[ $result == *$fe_path* ]]; then
|
||||
echo "|--------------------------------------------------------|"
|
||||
echo "|***** THERE ARE CHANGES INSIDE FOLDER $fe_path *****|"
|
||||
|
|
|
|||
|
|
@ -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 (*)
|
||||
|
|
|
|||
Loading…
Reference in New Issue