Initial Commit
parent
b07cb02384
commit
08eee36229
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "pm2-gay",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node src/index.js"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
const express = require('express')
|
||||
const app = express()
|
||||
const port = 3000
|
||||
const { exec } = require("child_process")
|
||||
const { WebhookClient, RichEmbed } = new require('discord.js')
|
||||
const webhook = new WebhookClient('e','e')
|
||||
app.use(express.json())
|
||||
|
||||
const path = {
|
||||
"app": "~/path/to/ur/app",
|
||||
"cock": "~/and/ball/tor/ture",
|
||||
"dame": "./dane"
|
||||
}
|
||||
|
||||
app.get('/pm2/is/fucking/gay', (req, res) => {
|
||||
res.status(418).send('418 THIS IS POST ENDPOINT GET IS HARA<M WEHGFOIEWBHGOUIREWBG{OIERWHGOI{WRHBs')
|
||||
})
|
||||
|
||||
app.post('/pm2/is/fucking/gay', (req, res) => {
|
||||
const payload = req.body
|
||||
|
||||
const embed = new RichEmbed()
|
||||
.setTitle('deploy or smth idfk')
|
||||
.setAuthor(payload.sender.login, payload.sender.avatar_url, payload.sender.url)
|
||||
.setDescription('Deployed from ' + payload.repository.full_name)
|
||||
.setColor(0x03fc0b)
|
||||
|
||||
if(!path[payload.repository.name]) return
|
||||
|
||||
for(const commit of payload.commits) {
|
||||
embed.addField(`${commit.id.slice(0,6)}`,`[__${commit.author.name}__](${commit.url}): ${commit.message}`)
|
||||
}
|
||||
|
||||
exec('git pull', { cwd: path[payload.repository.name] }, (error, stdout, stderr) => {
|
||||
if(error) {
|
||||
embed.setTitle('congrats your deploy is go bye bye')
|
||||
.setColor(0xfc0303)
|
||||
.setDescription('Deploy failed from ' + payload.repository.full_name)
|
||||
.addField('error', error.message)
|
||||
return
|
||||
}
|
||||
if(stderr) {
|
||||
embed.setTitle('congrats your deploy is go bye bye')
|
||||
.setColor(0xfc0303)
|
||||
.setDescription('Deploy failed from ' + payload.repository.full_name)
|
||||
.addField('error', stderr)
|
||||
return
|
||||
}
|
||||
addField('log', stdout)
|
||||
})
|
||||
|
||||
webhook.send({embeds: [embed]})
|
||||
res.sendStatus(204)
|
||||
})
|
||||
|
||||
app.all('*', (res, req) => res.send('h'))
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`qerguioperhgpoiqehgipoqea listening at http://localhost:${port}`)
|
||||
})
|
Loading…
Reference in New Issue