Added args to script
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,4 @@
|
||||
/data
|
||||
push-event.txt
|
||||
|
||||
|
||||
|
||||
|
||||
47
res/push-event.txt
Normal file
47
res/push-event.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"path": "/",
|
||||
"headers": {
|
||||
"host": "deployment:8888",
|
||||
"user-agent": "Go-http-client/1.1",
|
||||
"content-length": "450",
|
||||
"authorization": "ThisIsAHeader",
|
||||
"content-type": "application/json",
|
||||
"accept-encoding": "gzip"
|
||||
},
|
||||
"method": "POST",
|
||||
"body": "{\"type\":\"PUSH_ARTIFACT\",\"occur_at\":1642979840,\"operator\":\"admin\",\"event_data\":{\"resources\":[{\"digest\":\"sha256:4c2ce204be06227e55a2580d9be0b0281324ebecd2e5110dc9a708720adb4ab1\",\"tag\":\"latest\",\"resource_url\":\"docker.sebse.de/web-development/node-wannistesvorbei:latest\"}],\"repository\":{\"date_created\":1618826088,\"name\":\"node-wannistesvorbei\",\"namespace\":\"web-development\",\"repo_full_name\":\"web-development/node-wannistesvorbei\",\"repo_type\":\"private\"}}}",
|
||||
"fresh": false,
|
||||
"hostname": "deployment",
|
||||
"ip": "::ffff:192.168.80.3",
|
||||
"ips": [],
|
||||
"protocol": "http",
|
||||
"query": {},
|
||||
"subdomains": [],
|
||||
"xhr": false,
|
||||
"os": {
|
||||
"hostname": "63361c412549"
|
||||
},
|
||||
"connection": {},
|
||||
"json": {
|
||||
"type": "PUSH_ARTIFACT",
|
||||
"occur_at": 1642979840,
|
||||
"operator": "admin",
|
||||
"event_data": {
|
||||
"resources": [
|
||||
{
|
||||
"digest": "sha256:4c2ce204be06227e55a2580d9be0b0281324ebecd2e5110dc9a708720adb4ab1",
|
||||
"tag": "latest",
|
||||
"resource_url": "docker.sebse.de/web-development/node-wannistesvorbei:latest"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"date_created": 1618826088,
|
||||
"name": "node-wannistesvorbei",
|
||||
"namespace": "web-development",
|
||||
"repo_full_name": "web-development/node-wannistesvorbei",
|
||||
"repo_type": "private"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
::ffff:192.168.80.3 - - [23/Jan/2022:23:17:23 +0000] "POST / HTTP/1.1" 200 1632 "-" "Go-http-client/1.1"
|
||||
@@ -16,8 +16,8 @@ const timeouts: Record<string, NodeJS.Timeout> = {}
|
||||
|
||||
async function parsePushHook(webhook: PushWebhook) {
|
||||
const repository: string|undefined = webhook.event_data?.repository?.repo_full_name
|
||||
const tag = webhook.event_data?.resources?.[0]?.tag
|
||||
if (!repository || !tag) {
|
||||
const {tag, resource_url} = webhook.event_data?.resources?.[0] ?? { }
|
||||
if (!repository || !tag || !resource_url) {
|
||||
return
|
||||
}
|
||||
clearTimeout(timeouts[repository])
|
||||
@@ -27,7 +27,7 @@ async function parsePushHook(webhook: PushWebhook) {
|
||||
.replace(/[^\w\s/]/gi, '-')
|
||||
.replace(/\//gi, '_')
|
||||
try {
|
||||
const cp = spawn(`./${filename}.sh`, [], {
|
||||
const cp = spawn(`./${filename}.sh`, [tag, resource_url], {
|
||||
cwd: rootDir,
|
||||
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user