update email and REAME.md
This commit is contained in:
parent
57e9ab5d63
commit
19c6ea4d0d
12
README.md
12
README.md
|
|
@ -8,7 +8,7 @@
|
||||||
### 2) Access the folder you just cloned
|
### 2) Access the folder you just cloned
|
||||||
* root@root#
|
* root@root#
|
||||||
```sh
|
```sh
|
||||||
cd <path>/gitea_CICD
|
cd gitea_CICD
|
||||||
```
|
```
|
||||||
### 3) Check the directory path
|
### 3) Check the directory path
|
||||||
* root@root#
|
* root@root#
|
||||||
|
|
@ -17,13 +17,16 @@
|
||||||
```
|
```
|
||||||
* output: <path>/gitea_CICD
|
* output: <path>/gitea_CICD
|
||||||
|
|
||||||
### 4) Fill in environment variables
|
### 4) Fill in environment variables (*)
|
||||||
* root@root#
|
* root@root#
|
||||||
```sh
|
```sh
|
||||||
nano service/giteaService
|
nano service/giteaService
|
||||||
```
|
```
|
||||||
* GIT_USERNAME: Username of the git account.
|
* GIT_USERNAME: Username of the git account.
|
||||||
* GIT_PASSWORD: Password of the git account.
|
* GIT_PASSWORD: Password of the git account.
|
||||||
|
* GIT_BRANCH: The git branch is needed for the server.
|
||||||
|
* EMAIL_ADDRESS: Your email address.
|
||||||
|
* SEND_EMAIL: Turn on/off email sending feature.
|
||||||
* PROJECT_PATH: Root path of your project.
|
* PROJECT_PATH: Root path of your project.
|
||||||
* FE_PROJECT_PATH: Path of the front-end folder.
|
* FE_PROJECT_PATH: Path of the front-end folder.
|
||||||
* BE_PROJECT_PATH: Path of the back-end folder.
|
* BE_PROJECT_PATH: Path of the back-end folder.
|
||||||
|
|
@ -34,6 +37,8 @@
|
||||||
```sh
|
```sh
|
||||||
./install.sh
|
./install.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|

|
||||||
#### ** Note: **
|
#### ** Note: **
|
||||||
|
|
||||||
- Project gitea_CICD should be placed at the same folder level as your project
|
- Project gitea_CICD should be placed at the same folder level as your project
|
||||||
|
|
@ -44,4 +49,5 @@
|
||||||
|
|
||||||
- Depending on the technology your project uses, the "gitea_CICD/service/giteaHook.sh" file will be custom configured to match the technology.
|
- Depending on the technology your project uses, the "gitea_CICD/service/giteaHook.sh" file will be custom configured to match the technology.
|
||||||
|
|
||||||
**____ Joseph ____ **
|
**____ Joseph ____ **
|
||||||
|
|
||||||
|
|
|
||||||
16
index.js
16
index.js
|
|
@ -1,3 +1,4 @@
|
||||||
|
const fs = require("fs");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const app = express();
|
const app = express();
|
||||||
const { exec } = require("child_process");
|
const { exec } = require("child_process");
|
||||||
|
|
@ -5,12 +6,14 @@
|
||||||
|
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
app.post("/git/gitea-webhook", (req, res) => {
|
app.post("/git/gitea-webhook", async(req, res) => {
|
||||||
|
const contentFile = await fs.readFileSync("./service/giteaService", "utf8");
|
||||||
|
const checkSendMail = contentFile.split("\n").filter((i)=>i.includes("SEND_EMAIL"))[0]?.split("=")[1].trim()
|
||||||
|
const emailAddress = contentFile.split("\n").filter((i)=>i.includes("EMAIL_ADDRESS"))[0]?.split("=")[1].trim()
|
||||||
const giteaEvent = req.headers["x-gitea-event"];
|
const giteaEvent = req.headers["x-gitea-event"];
|
||||||
console.log("New event: "+giteaEvent)
|
console.log("New event: "+giteaEvent)
|
||||||
const body = req.body
|
const body = req.body
|
||||||
// console.log(body)
|
//console.log(body)
|
||||||
res.status(200).send({mess: "The event has been received!", data:req.body})
|
res.status(200).send({mess: "The event has been received!", data:req.body})
|
||||||
|
|
||||||
exec(
|
exec(
|
||||||
|
|
@ -21,6 +24,8 @@
|
||||||
// res.status(500).send("PULL ERROR")
|
// res.status(500).send("PULL ERROR")
|
||||||
}
|
}
|
||||||
console.log(stdout)
|
console.log(stdout)
|
||||||
|
|
||||||
|
if(checkSendMail==="True"){
|
||||||
const transporter = nodeMailer.createTransport({
|
const transporter = nodeMailer.createTransport({
|
||||||
|
|
||||||
pool: true,
|
pool: true,
|
||||||
|
|
@ -35,14 +40,15 @@
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
from: "admin@apactech.io",
|
from: "admin@apactech.io",
|
||||||
to: "joseph@apactech.io",
|
to: emailAddress,
|
||||||
subject: "New Git envent: "+giteaEvent ,
|
subject: "New Git envent: "+giteaEvent ,
|
||||||
html: "<h1>*** "+giteaEvent+" event ***</h1><h4>Committer: "+req.body.commits[0]?.committer.name+"</h4><h4>Message: "+req.body.commits[0]?.message+"</h4><a href='"+req.body.commits[0]?.url+"'>Link: "+req.body.commits[0]?.url+"</a><h4>Process output:</h4><textarea style='wordWrap:break-word; display: block; width:100%; height:70vh;border:solid 2px orange'>" +
|
html: "<h1>*** "+giteaEvent+" event ***</h1><h4>Committer: "+req.body.commits[0]?.committer.name+"</h4><h4>Message: "+req.body.commits[0]?.message+"</h4><h4>Branch: "+req.body.ref+"</h4><a href='"+req.body.commits[0]?.url+"'>Link: "+req.body.commits[0]?.url+"</a><h4>Process output:</h4><textarea style='wordWrap:break-word; display: block; width:100%; height:70vh;border:solid 2px orange'>" +
|
||||||
stdout +
|
stdout +
|
||||||
"</textarea>"
|
"</textarea>"
|
||||||
};
|
};
|
||||||
|
|
||||||
return transporter.sendMail(options);
|
return transporter.sendMail(options);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -318,6 +318,11 @@
|
||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fs": {
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
|
||||||
|
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
|
||||||
|
},
|
||||||
"node_modules/function-bind": {
|
"node_modules/function-bind": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Security holding package
|
||||||
|
|
||||||
|
This package name is not currently in use, but was formerly occupied
|
||||||
|
by another package. To avoid malicious use, npm is hanging on to the
|
||||||
|
package name, but loosely, and we'll probably give it to you if you
|
||||||
|
want it.
|
||||||
|
|
||||||
|
You may adopt this package by contacting support@npmjs.com and
|
||||||
|
requesting the name.
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"name": "fs",
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/npm/security-holder.git"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/npm/security-holder/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/npm/security-holder#readme"
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"child_process": "^1.0.2",
|
"child_process": "^1.0.2",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
|
"fs": "^0.0.1-security",
|
||||||
"nodemailer": "^6.9.5",
|
"nodemailer": "^6.9.5",
|
||||||
"nodemon": "^3.0.1"
|
"nodemon": "^3.0.1"
|
||||||
}
|
}
|
||||||
|
|
@ -329,6 +330,11 @@
|
||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fs": {
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
|
||||||
|
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
|
||||||
|
},
|
||||||
"node_modules/fsevents": {
|
"node_modules/fsevents": {
|
||||||
"version": "2.3.3",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||||
|
|
@ -1208,6 +1214,11 @@
|
||||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||||
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="
|
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="
|
||||||
},
|
},
|
||||||
|
"fs": {
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
|
||||||
|
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
|
||||||
|
},
|
||||||
"fsevents": {
|
"fsevents": {
|
||||||
"version": "2.3.3",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"child_process": "^1.0.2",
|
"child_process": "^1.0.2",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
|
"fs": "^0.0.1-security",
|
||||||
"nodemailer": "^6.9.5",
|
"nodemailer": "^6.9.5",
|
||||||
"nodemon": "^3.0.1"
|
"nodemon": "^3.0.1"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,11 @@ GIT_USERNAME=joseph.le@apactech.io
|
||||||
GIT_PASSWORD=Maypjtkh0ng
|
GIT_PASSWORD=Maypjtkh0ng
|
||||||
GIT_BRANCH=dev
|
GIT_BRANCH=dev
|
||||||
|
|
||||||
|
#Email
|
||||||
|
EMAIL_ADDRESS=joseph@apactech.io
|
||||||
|
#Send mail: True or False
|
||||||
|
SEND_EMAIL=False
|
||||||
|
|
||||||
#Duong dan goc cua project (*)
|
#Duong dan goc cua project (*)
|
||||||
PROJECT_PATH=/home/joseph/Demo_Git_Webhook
|
PROJECT_PATH=/home/joseph/Demo_Git_Webhook
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue