summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLinnnus <[email protected]>2024-10-01 22:29:21 +0200
committerLinnnus <[email protected]>2024-10-01 22:29:21 +0200
commitf5c119fdaf444fc0b1b59c1e07fd32a5f6ddf069 (patch)
treefd63a803e3ffa3b9e1c05549ae29eeace7adbcf0 /examples
Initial commit
Diffstat (limited to 'examples')
-rw-r--r--examples/config.json20
-rw-r--r--examples/sample_push_event.http35
-rwxr-xr-xexamples/sample_push_event.sh14
-rw-r--r--examples/sample_push_payload.json1
-rw-r--r--examples/secret.txt1
5 files changed, 71 insertions, 0 deletions
diff --git a/examples/config.json b/examples/config.json
new file mode 100644
index 0000000..6cbdade
--- /dev/null
+++ b/examples/config.json
@@ -0,0 +1,20 @@
+{
+ "secret_file": "./examples/secret.txt",
+
+ "commands": [
+ {
+ "event": "ping",
+ "command": "/bin/echo",
+ "args": [
+ "Got ping event!!"
+ ]
+ },
+ {
+ "event": "push",
+ "command": "/bin/echo",
+ "args": [
+ "Got push event!!"
+ ]
+ }
+ ]
+}
diff --git a/examples/sample_push_event.http b/examples/sample_push_event.http
new file mode 100644
index 0000000..1dc7733
--- /dev/null
+++ b/examples/sample_push_event.http
@@ -0,0 +1,35 @@
+POST / HTTP/1.1
+host: 127.0.0.1:3000
+connection: keep-alive
+accept: */*
+user-agent: GitHub-Hookshot/140ebc7
+max-forwards: 10
+x-github-delivery: 7543c24a-7d8f-11ef-9348-3b472df99429
+x-github-event: push
+x-github-hook-id: 504318719
+x-github-hook-installation-target-id: 864484957
+x-github-hook-installation-target-type: repository
+x-hub-signature: sha1=c7ef177a009e1f520dde1223db1ae4daaa17e3c6
+x-hub-signature-256: sha256=fa6bf4d04aa55738642d45048fab71e48fc0539bcbd8fdce03baee7445c3d2c6
+x-arr-log-id: 18da17d1-a836-45fe-9727-e5f965891cac
+client-ip: 140.82.115.62:37220
+x-client-ip: 140.82.115.62
+disguised-host: smee.io
+x-site-deployment-id: smee-io-production
+was-default-hostname: smee-io-production.azurewebsites.net
+x-forwarded-proto: https
+x-appservice-proto: https
+x-arr-ssl: 2048|256|CN=GeoTrust Global TLS RSA4096 SHA256 2022 CA1, O="DigiCert, Inc.", C=US|CN=smee.io
+x-forwarded-tlsversion: 1.3
+x-forwarded-for: 140.82.115.62:37220
+x-original-url: /t0jT9nlFA215qVm6
+x-waws-unencoded-url: /t0jT9nlFA215qVm6
+x-client-port: 37220
+content-type: application/json
+timestamp: 1727773997174
+accept-language: *
+sec-fetch-mode: cors
+accept-encoding: gzip, deflate
+content-length: 7413
+
+{"ref":"refs/heads/main","before":"407e6275cc14390538c216a05049cc363c800af9","after":"06fa4075dc962e265c7d0f4d00d6eea5e390ac65","repository":{"id":864484957,"node_id":"R_kgDOM4b-XQ","name":"webhook-test","full_name":"linnnus/webhook-test","private":true,"owner":{"name":"linnnus","email":"[email protected]","login":"linnnus","id":64274485,"node_id":"MDQ6VXNlcjY0Mjc0NDg1","avatar_url":"https://avatars.githubusercontent.com/u/64274485?v=4","gravatar_id":"","url":"https://api.github.com/users/linnnus","html_url":"https://github.com/linnnus","followers_url":"https://api.github.com/users/linnnus/followers","following_url":"https://api.github.com/users/linnnus/following{/other_user}","gists_url":"https://api.github.com/users/linnnus/gists{/gist_id}","starred_url":"https://api.github.com/users/linnnus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linnnus/subscriptions","organizations_url":"https://api.github.com/users/linnnus/orgs","repos_url":"https://api.github.com/users/linnnus/repos","events_url":"https://api.github.com/users/linnnus/events{/privacy}","received_events_url":"https://api.github.com/users/linnnus/received_events","type":"User","site_admin":false},"html_url":"https://github.com/linnnus/webhook-test","description":"A GitHub repository I can use to test GitHub's webhook functionality","fork":false,"url":"https://github.com/linnnus/webhook-test","forks_url":"https://api.github.com/repos/linnnus/webhook-test/forks","keys_url":"https://api.github.com/repos/linnnus/webhook-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linnnus/webhook-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linnnus/webhook-test/teams","hooks_url":"https://api.github.com/repos/linnnus/webhook-test/hooks","issue_events_url":"https://api.github.com/repos/linnnus/webhook-test/issues/events{/number}","events_url":"https://api.github.com/repos/linnnus/webhook-test/events","assignees_url":"https://api.github.com/repos/linnnus/webhook-test/assignees{/user}","branches_url":"https://api.github.com/repos/linnnus/webhook-test/branches{/branch}","tags_url":"https://api.github.com/repos/linnnus/webhook-test/tags","blobs_url":"https://api.github.com/repos/linnnus/webhook-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linnnus/webhook-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linnnus/webhook-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/linnnus/webhook-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linnnus/webhook-test/statuses/{sha}","languages_url":"https://api.github.com/repos/linnnus/webhook-test/languages","stargazers_url":"https://api.github.com/repos/linnnus/webhook-test/stargazers","contributors_url":"https://api.github.com/repos/linnnus/webhook-test/contributors","subscribers_url":"https://api.github.com/repos/linnnus/webhook-test/subscribers","subscription_url":"https://api.github.com/repos/linnnus/webhook-test/subscription","commits_url":"https://api.github.com/repos/linnnus/webhook-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/linnnus/webhook-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/linnnus/webhook-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/linnnus/webhook-test/issues/comments{/number}","contents_url":"https://api.github.com/repos/linnnus/webhook-test/contents/{+path}","compare_url":"https://api.github.com/repos/linnnus/webhook-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linnnus/webhook-test/merges","archive_url":"https://api.github.com/repos/linnnus/webhook-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linnnus/webhook-test/downloads","issues_url":"https://api.github.com/repos/linnnus/webhook-test/issues{/number}","pulls_url":"https://api.github.com/repos/linnnus/webhook-test/pulls{/number}","milestones_url":"https://api.github.com/repos/linnnus/webhook-test/milestones{/number}","notifications_url":"https://api.github.com/repos/linnnus/webhook-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linnnus/webhook-test/labels{/name}","releases_url":"https://api.github.com/repos/linnnus/webhook-test/releases{/id}","deployments_url":"https://api.github.com/repos/linnnus/webhook-test/deployments","created_at":1727520330,"updated_at":"2024-09-28T10:45:50Z","pushed_at":1727524056,"git_url":"git://github.com/linnnus/webhook-test.git","ssh_url":"[email protected]:linnnus/webhook-test.git","clone_url":"https://github.com/linnnus/webhook-test.git","svn_url":"https://github.com/linnnus/webhook-test","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":null,"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"private","forks":0,"open_issues":0,"watchers":0,"default_branch":"main","stargazers":0,"master_branch":"main"},"pusher":{"name":"linnnus","email":"[email protected]"},"sender":{"login":"linnnus","id":64274485,"node_id":"MDQ6VXNlcjY0Mjc0NDg1","avatar_url":"https://avatars.githubusercontent.com/u/64274485?v=4","gravatar_id":"","url":"https://api.github.com/users/linnnus","html_url":"https://github.com/linnnus","followers_url":"https://api.github.com/users/linnnus/followers","following_url":"https://api.github.com/users/linnnus/following{/other_user}","gists_url":"https://api.github.com/users/linnnus/gists{/gist_id}","starred_url":"https://api.github.com/users/linnnus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linnnus/subscriptions","organizations_url":"https://api.github.com/users/linnnus/orgs","repos_url":"https://api.github.com/users/linnnus/repos","events_url":"https://api.github.com/users/linnnus/events{/privacy}","received_events_url":"https://api.github.com/users/linnnus/received_events","type":"User","site_admin":false},"created":false,"deleted":false,"forced":false,"base_ref":null,"compare":"https://github.com/linnnus/webhook-test/compare/407e6275cc14...06fa4075dc96","commits":[{"id":"06fa4075dc962e265c7d0f4d00d6eea5e390ac65","tree_id":"35037f100f45d4854269ee454e12e7ade22db510","distinct":true,"message":"fix everything","timestamp":"2024-09-28T13:47:35+02:00","url":"https://github.com/linnnus/webhook-test/commit/06fa4075dc962e265c7d0f4d00d6eea5e390ac65","author":{"name":"Linnnus","email":"[email protected]","username":"linnnus"},"committer":{"name":"Linnnus","email":"[email protected]","username":"linnnus"},"added":[],"removed":[],"modified":["README.md"]}],"head_commit":{"id":"06fa4075dc962e265c7d0f4d00d6eea5e390ac65","tree_id":"35037f100f45d4854269ee454e12e7ade22db510","distinct":true,"message":"fix everything","timestamp":"2024-09-28T13:47:35+02:00","url":"https://github.com/linnnus/webhook-test/commit/06fa4075dc962e265c7d0f4d00d6eea5e390ac65","author":{"name":"Linnnus","email":"[email protected]","username":"linnnus"},"committer":{"name":"Linnnus","email":"[email protected]","username":"linnnus"},"added":[],"removed":[],"modified":["README.md"]}} \ No newline at end of file
diff --git a/examples/sample_push_event.sh b/examples/sample_push_event.sh
new file mode 100755
index 0000000..362d621
--- /dev/null
+++ b/examples/sample_push_event.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Expects service to be listening on socket
+# Expects to be run from project root
+# Payload signed with 'mysecret'
+
+curl --unix-socket /tmp/websocket-listener.sock http://localhost/ \
+ -X POST \
+ --data @./examples/sample_push_payload.json \
+ -H 'X-Github-Event: push' \
+ -H 'X-Hub-Signature-256: sha256=6803d2a3e495fc4bd286d428ea4b794476a1ff1b72bbea4dfafd2477d5d89188' \
+ -H 'Content-Length: 7413' \
+ -H 'Content-Type: application/json' \
+ -v
diff --git a/examples/sample_push_payload.json b/examples/sample_push_payload.json
new file mode 100644
index 0000000..bffdcd0
--- /dev/null
+++ b/examples/sample_push_payload.json
@@ -0,0 +1 @@
+{"ref":"refs/heads/main","before":"407e6275cc14390538c216a05049cc363c800af9","after":"06fa4075dc962e265c7d0f4d00d6eea5e390ac65","repository":{"id":864484957,"node_id":"R_kgDOM4b-XQ","name":"webhook-test","full_name":"linnnus/webhook-test","private":true,"owner":{"name":"linnnus","email":"[email protected]","login":"linnnus","id":64274485,"node_id":"MDQ6VXNlcjY0Mjc0NDg1","avatar_url":"https://avatars.githubusercontent.com/u/64274485?v=4","gravatar_id":"","url":"https://api.github.com/users/linnnus","html_url":"https://github.com/linnnus","followers_url":"https://api.github.com/users/linnnus/followers","following_url":"https://api.github.com/users/linnnus/following{/other_user}","gists_url":"https://api.github.com/users/linnnus/gists{/gist_id}","starred_url":"https://api.github.com/users/linnnus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linnnus/subscriptions","organizations_url":"https://api.github.com/users/linnnus/orgs","repos_url":"https://api.github.com/users/linnnus/repos","events_url":"https://api.github.com/users/linnnus/events{/privacy}","received_events_url":"https://api.github.com/users/linnnus/received_events","type":"User","site_admin":false},"html_url":"https://github.com/linnnus/webhook-test","description":"A GitHub repository I can use to test GitHub's webhook functionality","fork":false,"url":"https://github.com/linnnus/webhook-test","forks_url":"https://api.github.com/repos/linnnus/webhook-test/forks","keys_url":"https://api.github.com/repos/linnnus/webhook-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linnnus/webhook-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linnnus/webhook-test/teams","hooks_url":"https://api.github.com/repos/linnnus/webhook-test/hooks","issue_events_url":"https://api.github.com/repos/linnnus/webhook-test/issues/events{/number}","events_url":"https://api.github.com/repos/linnnus/webhook-test/events","assignees_url":"https://api.github.com/repos/linnnus/webhook-test/assignees{/user}","branches_url":"https://api.github.com/repos/linnnus/webhook-test/branches{/branch}","tags_url":"https://api.github.com/repos/linnnus/webhook-test/tags","blobs_url":"https://api.github.com/repos/linnnus/webhook-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linnnus/webhook-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linnnus/webhook-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/linnnus/webhook-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linnnus/webhook-test/statuses/{sha}","languages_url":"https://api.github.com/repos/linnnus/webhook-test/languages","stargazers_url":"https://api.github.com/repos/linnnus/webhook-test/stargazers","contributors_url":"https://api.github.com/repos/linnnus/webhook-test/contributors","subscribers_url":"https://api.github.com/repos/linnnus/webhook-test/subscribers","subscription_url":"https://api.github.com/repos/linnnus/webhook-test/subscription","commits_url":"https://api.github.com/repos/linnnus/webhook-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/linnnus/webhook-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/linnnus/webhook-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/linnnus/webhook-test/issues/comments{/number}","contents_url":"https://api.github.com/repos/linnnus/webhook-test/contents/{+path}","compare_url":"https://api.github.com/repos/linnnus/webhook-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linnnus/webhook-test/merges","archive_url":"https://api.github.com/repos/linnnus/webhook-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linnnus/webhook-test/downloads","issues_url":"https://api.github.com/repos/linnnus/webhook-test/issues{/number}","pulls_url":"https://api.github.com/repos/linnnus/webhook-test/pulls{/number}","milestones_url":"https://api.github.com/repos/linnnus/webhook-test/milestones{/number}","notifications_url":"https://api.github.com/repos/linnnus/webhook-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linnnus/webhook-test/labels{/name}","releases_url":"https://api.github.com/repos/linnnus/webhook-test/releases{/id}","deployments_url":"https://api.github.com/repos/linnnus/webhook-test/deployments","created_at":1727520330,"updated_at":"2024-09-28T10:45:50Z","pushed_at":1727524056,"git_url":"git://github.com/linnnus/webhook-test.git","ssh_url":"[email protected]:linnnus/webhook-test.git","clone_url":"https://github.com/linnnus/webhook-test.git","svn_url":"https://github.com/linnnus/webhook-test","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":null,"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"private","forks":0,"open_issues":0,"watchers":0,"default_branch":"main","stargazers":0,"master_branch":"main"},"pusher":{"name":"linnnus","email":"[email protected]"},"sender":{"login":"linnnus","id":64274485,"node_id":"MDQ6VXNlcjY0Mjc0NDg1","avatar_url":"https://avatars.githubusercontent.com/u/64274485?v=4","gravatar_id":"","url":"https://api.github.com/users/linnnus","html_url":"https://github.com/linnnus","followers_url":"https://api.github.com/users/linnnus/followers","following_url":"https://api.github.com/users/linnnus/following{/other_user}","gists_url":"https://api.github.com/users/linnnus/gists{/gist_id}","starred_url":"https://api.github.com/users/linnnus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linnnus/subscriptions","organizations_url":"https://api.github.com/users/linnnus/orgs","repos_url":"https://api.github.com/users/linnnus/repos","events_url":"https://api.github.com/users/linnnus/events{/privacy}","received_events_url":"https://api.github.com/users/linnnus/received_events","type":"User","site_admin":false},"created":false,"deleted":false,"forced":false,"base_ref":null,"compare":"https://github.com/linnnus/webhook-test/compare/407e6275cc14...06fa4075dc96","commits":[{"id":"06fa4075dc962e265c7d0f4d00d6eea5e390ac65","tree_id":"35037f100f45d4854269ee454e12e7ade22db510","distinct":true,"message":"fix everything","timestamp":"2024-09-28T13:47:35+02:00","url":"https://github.com/linnnus/webhook-test/commit/06fa4075dc962e265c7d0f4d00d6eea5e390ac65","author":{"name":"Linnnus","email":"[email protected]","username":"linnnus"},"committer":{"name":"Linnnus","email":"[email protected]","username":"linnnus"},"added":[],"removed":[],"modified":["README.md"]}],"head_commit":{"id":"06fa4075dc962e265c7d0f4d00d6eea5e390ac65","tree_id":"35037f100f45d4854269ee454e12e7ade22db510","distinct":true,"message":"fix everything","timestamp":"2024-09-28T13:47:35+02:00","url":"https://github.com/linnnus/webhook-test/commit/06fa4075dc962e265c7d0f4d00d6eea5e390ac65","author":{"name":"Linnnus","email":"[email protected]","username":"linnnus"},"committer":{"name":"Linnnus","email":"[email protected]","username":"linnnus"},"added":[],"removed":[],"modified":["README.md"]}} \ No newline at end of file
diff --git a/examples/secret.txt b/examples/secret.txt
new file mode 100644
index 0000000..7776823
--- /dev/null
+++ b/examples/secret.txt
@@ -0,0 +1 @@
+mysecret \ No newline at end of file