update index.js, env
This commit is contained in:
parent
148c52c103
commit
fa09ae76bb
|
|
@ -5,7 +5,7 @@
|
||||||
### 1) Clone project to your server
|
### 1) Clone project to your server
|
||||||
|
|
||||||
```sh
|
```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:
|
- Get username:
|
||||||
<div><img src="https://i.ibb.co/pLR2BjH/image.png" alt="getUsername" width="300"></div>
|
<div><img src="https://i.ibb.co/pLR2BjH/image.png" alt="getUsername" width="300"></div>
|
||||||
|
|
|
||||||
16
index.js
16
index.js
|
|
@ -3,14 +3,19 @@ const express = require("express");
|
||||||
const app = express();
|
const app = express();
|
||||||
const { exec } = require("child_process");
|
const { exec } = require("child_process");
|
||||||
const nodeMailer = require("nodemailer");
|
const nodeMailer = require("nodemailer");
|
||||||
|
const contentFile = fs.readFileSync(
|
||||||
app.use(express.json());
|
|
||||||
|
|
||||||
app.post("/git/gitea-webhook", async (req, res) => {
|
|
||||||
const contentFile = await fs.readFileSync(
|
|
||||||
"./service_run/giteaService.conf",
|
"./service_run/giteaService.conf",
|
||||||
"utf8"
|
"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
|
const checkSendMail = contentFile
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.filter((i) => i.includes("SEND_EMAIL"))[0]
|
.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, () => {
|
app.listen(PORT, () => {
|
||||||
console.log("Server is running on port ", PORT);
|
console.log("Server is running on port ", PORT);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -38,24 +38,7 @@ function run_commands() {
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
result=$(expect -c "
|
result=$(spawn git pull origin $GIT_BRANCH) &&
|
||||||
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" &&
|
echo "$result" &&
|
||||||
if [[ $result == *$fe_path* ]]; then
|
if [[ $result == *$fe_path* ]]; then
|
||||||
echo "|--------------------------------------------------------|"
|
echo "|--------------------------------------------------------|"
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@
|
||||||
HOOK_PATH=/home/gitea_CICD
|
HOOK_PATH=/home/gitea_CICD
|
||||||
|
|
||||||
# Git account (*)
|
# Git account (*)
|
||||||
GIT_USERNAME=<your_username>
|
|
||||||
GIT_PASSWORD=<your_password>
|
|
||||||
GIT_BRANCH=<your_branch>
|
GIT_BRANCH=<your_branch>
|
||||||
|
|
||||||
|
# Port of server (*)
|
||||||
|
PORT_SERVICE=5000
|
||||||
|
|
||||||
# Email: Used to send notifications when the repository has updates (*)
|
# Email: Used to send notifications when the repository has updates (*)
|
||||||
EMAIL_ADDRESS=<youremail>
|
EMAIL_ADDRESS=<youremail>
|
||||||
# Enable/Disable send mail: True or False (*)
|
# Enable/Disable send mail: True or False (*)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue