github webhook to github actions workflow dispatch
const got = require('got')
const express = require("@runkit/runkit/express-endpoint/1.0.0")
const bodyParser = require("body-parser")
const app = express(exports)
app.use(bodyParser.urlencoded())
app.use("/", (req, res, next) => {
if (!req.query.key || req.query.key !== process.env.WEBHOOK_KEY) {
return res.status(403).send("forbidden")
}
return next()
})
app.all("*", async (req, res) => {
const result = await got.post("https://api.github.com", {
path: req.path,
headers: {
"Authorization": "token " + process.env.GH_PAT,
"Accept": "application/vnd.github.v3+json"
},
json: {
ref: "master"
},
responseType: 'json'
})
return res.send(result.statusCode)
})
no comments