Skip to content

Commit 731078e

Browse files
committed
init : init webhook script
0 parents  commit 731078e

File tree

5 files changed

+224
-0
lines changed

5 files changed

+224
-0
lines changed

.gitignore

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Custom
2+
tmp/*
3+
.vscode/*
4+
dist/
5+
6+
# JetBrain
7+
.idea
8+
.DS_Store
9+
10+
### OSX template
11+
12+
*.DS_Store
13+
.AppleDouble
14+
.LSOverride
15+
16+
# Icon must end with two \r
17+
Icon
18+
19+
# Thumbnails
20+
._*
21+
22+
# Files that might appear in the root of a volume
23+
.DocumentRevisions-V100
24+
.fseventsd
25+
.Spotlight-V100
26+
.TemporaryItems
27+
.Trashes
28+
.VolumeIcon.icns
29+
.com.apple.timemachine.donotpresent
30+
31+
# Directories potentially created on remote AFP share
32+
.AppleDB
33+
.AppleDesktop
34+
Network Trash Folder
35+
Temporary Items
36+
.apdisk
37+
38+
### Node template
39+
40+
# Logs
41+
42+
logs
43+
*.log
44+
npm-debug.log*
45+
46+
# Runtime data
47+
pids
48+
*.pid
49+
*.seed
50+
51+
# Directory for instrumented libs generated by jscoverage/JSCover
52+
lib-cov
53+
54+
# Coverage directory used by tools like istanbul
55+
coverage
56+
57+
# nyc test coverage
58+
.nyc_output
59+
60+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
61+
.grunt
62+
63+
# node-waf configuration
64+
.lock-wscript
65+
66+
# Compiled binary addons (http://nodejs.org/api/addons.html)
67+
build/Release
68+
69+
# Dependency directories
70+
node_modules
71+
jspm_packages
72+
73+
# Optional npm cache directory
74+
.npm
75+
76+
# Optional REPL history
77+
.node_repl_history
78+
79+
80+
### Windows template
81+
# Windows image file caches
82+
Thumbs.db
83+
ehthumbs.db
84+
85+
# Folder config file
86+
Desktop.ini
87+
88+
# Recycle Bin used on file shares
89+
$RECYCLE.BIN/
90+
91+
# Windows Installer files
92+
*.cab
93+
*.msi
94+
*.msm
95+
*.msp
96+
97+
# Windows shortcuts
98+
*.lnk

README.md

Whitespace-only changes.

index.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var http = require("http");
2+
var spawn = require("child_process").spawn;
3+
var createHandler = require("github-webhook-handler");
4+
// 下面填写的myscrect跟github webhooks配置一样,下一步会说;path是我们访问的路径
5+
var handler = createHandler({
6+
path: "/auto_build",
7+
secret: "120.79.243.104:803"
8+
});
9+
http
10+
.createServer(function(req, res) {
11+
handler(req, res, function(err) {
12+
res.statusCode = 404;
13+
res.end("no such location");
14+
});
15+
})
16+
.listen(803);
17+
handler.on("error", function(err) {
18+
console.error("Error:", err.message);
19+
});
20+
// 监听到push事件的时候执行我们的自动化脚本
21+
handler.on("push", function(event) {
22+
console.log(
23+
"Received a push event for %s to %s",
24+
event.payload.repository.name,
25+
event.payload.ref
26+
);
27+
// runCommand("sh", ["./auto_build.sh"], function(txt) {
28+
// console.log(txt);
29+
// });
30+
});
31+
function rumCommand(cmd, args, callback) {
32+
var child = spawn(cmd, args);
33+
var response = "";
34+
child.stdout.on("data", function(buffer) {
35+
resp += buffer.toString();
36+
});
37+
child.stdout.on("end", function() {
38+
callback(resp);
39+
});
40+
}
41+
// 由于我们不需要监听issues,所以下面代码注释掉
42+
// handler.on('issues', function (event) {
43+
// console.log('Received an issue event for %s action=%s: #%d %s',
44+
// event.payload.repository.name,
45+
// event.payload.action,
46+
// event.payload.issue.number,
47+
// event.payload.issue.title)
48+
// });

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "gitbub-webhook",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/coderiver-org/gitbub-webhook.git"
12+
},
13+
"keywords": [],
14+
"author": "",
15+
"license": "ISC",
16+
"bugs": {
17+
"url": "https://github.com/coderiver-org/gitbub-webhook/issues"
18+
},
19+
"homepage": "https://github.com/coderiver-org/gitbub-webhook#readme",
20+
"dependencies": {
21+
"github-webhook-handler": "^0.7.1"
22+
}
23+
}

yarn.lock

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
bl@~1.1.2:
6+
version "1.1.2"
7+
resolved "http://registry.npm.taobao.org/bl/download/bl-1.1.2.tgz#fdca871a99713aa00d19e3bbba41c44787a65398"
8+
dependencies:
9+
readable-stream "~2.0.5"
10+
11+
buffer-equal-constant-time@~1.0.1:
12+
version "1.0.1"
13+
resolved "http://registry.npm.taobao.org/buffer-equal-constant-time/download/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819"
14+
15+
core-util-is@~1.0.0:
16+
version "1.0.2"
17+
resolved "http://registry.npm.taobao.org/core-util-is/download/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
18+
19+
github-webhook-handler@^0.7.1:
20+
version "0.7.1"
21+
resolved "http://registry.npm.taobao.org/github-webhook-handler/download/github-webhook-handler-0.7.1.tgz#129a32911f0f7db16e2951cee61107965d55cf89"
22+
dependencies:
23+
bl "~1.1.2"
24+
buffer-equal-constant-time "~1.0.1"
25+
26+
inherits@~2.0.1:
27+
version "2.0.3"
28+
resolved "http://registry.npm.taobao.org/inherits/download/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
29+
30+
isarray@~1.0.0:
31+
version "1.0.0"
32+
resolved "http://registry.npm.taobao.org/isarray/download/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
33+
34+
process-nextick-args@~1.0.6:
35+
version "1.0.7"
36+
resolved "http://registry.npm.taobao.org/process-nextick-args/download/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3"
37+
38+
readable-stream@~2.0.5:
39+
version "2.0.6"
40+
resolved "http://registry.npm.taobao.org/readable-stream/download/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e"
41+
dependencies:
42+
core-util-is "~1.0.0"
43+
inherits "~2.0.1"
44+
isarray "~1.0.0"
45+
process-nextick-args "~1.0.6"
46+
string_decoder "~0.10.x"
47+
util-deprecate "~1.0.1"
48+
49+
string_decoder@~0.10.x:
50+
version "0.10.31"
51+
resolved "http://registry.npm.taobao.org/string_decoder/download/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94"
52+
53+
util-deprecate@~1.0.1:
54+
version "1.0.2"
55+
resolved "http://registry.npm.taobao.org/util-deprecate/download/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy