Compare commits

..

No commits in common. "71ffc9b6c1ffe59ca0d975c0373ba4790aa7a83a" and "32eb073b4a54e85eec7baec83ae3c85778bce01d" have entirely different histories.

3 changed files with 9 additions and 22 deletions

View File

@ -1,3 +1 @@
PORT="5000"
SECRET_KEY=""
EXECUTE_SCRIPT=""
SECRET_KEY=""

View File

@ -1,14 +1,11 @@
// The base for this script was shameless copied from https://discourse.gitea.io/t/how-to-write-a-webhook-in-gitea-in-node-js-javascript/1907
const express = require('express')
const crypto = require('crypto')
const bodyParser = require('body-parser')
const { exec } = require('child_process')
require('dotenv').config()
const SECRET = process.env.SECRET_KEY
const app = express()
const port = process.env.PORT
const port = 9000
const options = {
inflate: true,
@ -17,7 +14,7 @@ const options = {
}
app.use(bodyParser.raw(options))
app.post('/', (req, res) => {
app.post('/buildhook', (req, res) => {
const signature = req.headers['x-gitea-signature']
if (!signature) {
console.error('x-gitea-signature missing')
@ -34,18 +31,12 @@ app.post('/', (req, res) => {
}
const json = JSON.parse(req.body.toString())
console.log(json.repository.clone_url)
// SIGNATURES MATCHES, do your thing here.
var buildscript = exec('sh ' + process.env.EXECUTE_SCRIPT, (error, stdout, stderr) => {
console.log(stdout);
console.log(stderr);
if (error !== null) {
console.log(`exec error: ${error}`);
}
});
console.log('json')
console.log(json)
res.sendStatus(200);
// SIGNATURES MATCHES, do your thing here.
res.send('success')
})
app.listen(port, () => {

View File

@ -11,9 +11,7 @@
"license": "MIT",
"dependencies": {
"dotenv": "^14.2.0",
"express": "^4.17.2"
},
"devDependencies": {
"express": "^4.17.2",
"nodemon": "^2.0.15"
}
}