Cleanup
This commit is contained in:
@@ -3,7 +3,6 @@ import 'dotenv/config'
|
|||||||
import * as env from 'env-var'
|
import * as env from 'env-var'
|
||||||
import { PushWebhook } from "./PushWebhook";
|
import { PushWebhook } from "./PushWebhook";
|
||||||
import { exec } from "child_process";
|
import { exec } from "child_process";
|
||||||
import { promisify } from "util";
|
|
||||||
|
|
||||||
const app: Application = express()
|
const app: Application = express()
|
||||||
|
|
||||||
@@ -29,11 +28,10 @@ async function parsePushHook(webhook: PushWebhook) {
|
|||||||
.replace(/\//gi, '_')
|
.replace(/\//gi, '_')
|
||||||
const safeTag = tag
|
const safeTag = tag
|
||||||
.replace(/[^a-z0-9-]/gi, '')
|
.replace(/[^a-z0-9-]/gi, '')
|
||||||
const safeResourceUri = tag
|
const safeResourceUri = resource_url
|
||||||
.replace(/[^a-z0-9-./:]/gi, '')
|
.replace(/[^a-z0-9-./:]/gi, '')
|
||||||
try {
|
try {
|
||||||
const cmd = `${rootDir}/${safeFilename}.sh ${safeTag} ${safeResourceUri}`
|
const cmd = `${rootDir}/${safeFilename}.sh ${safeTag} ${safeResourceUri}`
|
||||||
console.log(cmd)
|
|
||||||
await new Promise(((resolve, reject) => {
|
await new Promise(((resolve, reject) => {
|
||||||
exec(cmd, (err, stdout, stderr) =>
|
exec(cmd, (err, stdout, stderr) =>
|
||||||
(err || stderr) ? reject(err || stderr) : resolve(stdout)
|
(err || stderr) ? reject(err || stderr) : resolve(stdout)
|
||||||
@@ -51,7 +49,6 @@ app.post('/', async (req: Request, res: Response) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const body: PushWebhook = req.body
|
const body: PushWebhook = req.body
|
||||||
console.log(JSON.stringify(body, null, 2))
|
|
||||||
if (body?.type !== "PUSH_ARTIFACT") {
|
if (body?.type !== "PUSH_ARTIFACT") {
|
||||||
res.status(400).json({msg: "Only push hooks are allowed!"})
|
res.status(400).json({msg: "Only push hooks are allowed!"})
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user