{"id":15951117,"url":"https://github.com/ldez/ghwebhook","last_synced_at":"2025-05-07T03:45:10.967Z","repository":{"id":57487673,"uuid":"99502787","full_name":"ldez/ghwebhook","owner":"ldez","description":"GHWebHook: create a GitHub Web Hook in 5 seconds with Go.","archived":false,"fork":false,"pushed_at":"2025-02-09T23:49:20.000Z","size":143,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T03:45:05.338Z","etag":null,"topics":["github","golang","webhooks"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/ldez/ghwebhook/v4","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ldez.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"ldez","ko_fi":"ldez_oss","liberapay":"ldez","thanks_dev":"u/gh/ldez"}},"created_at":"2017-08-06T17:34:42.000Z","updated_at":"2025-02-09T23:49:24.000Z","dependencies_parsed_at":"2024-06-19T06:14:29.005Z","dependency_job_id":"fcad9d1f-913e-4bd9-a7e9-34ba1ee96ea9","html_url":"https://github.com/ldez/ghwebhook","commit_stats":{"total_commits":61,"total_committers":3,"mean_commits":"20.333333333333332","dds":0.2622950819672131,"last_synced_commit":"08b839de09d79d4aace762d75cd62c46d278366a"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Fghwebhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Fghwebhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Fghwebhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldez%2Fghwebhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ldez","download_url":"https://codeload.github.com/ldez/ghwebhook/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252810273,"owners_count":21807759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","golang","webhooks"],"created_at":"2024-10-07T13:01:23.224Z","updated_at":"2025-05-07T03:45:10.951Z","avatar_url":"https://github.com/ldez.png","language":"Go","readme":"# GHWebHook\n\n[![release](https://img.shields.io/github/tag/ldez/ghwebhook.svg)](https://github.com/ldez/ghwebhook/releases)\n[![Build Status](https://github.com/ldez/ghwebhook/workflows/Main/badge.svg?branch=master)](https://github.com/ldez/ghwebhook/actions)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/ldez/ghwebhook)](https://pkg.go.dev/github.com/ldez/ghwebhook/v4)\n\n[![Sponsor](https://img.shields.io/badge/Sponsor%20me-%E2%9D%A4%EF%B8%8F-pink)](https://github.com/sponsors/ldez)\n\nCreate a GitHub WebHook in 5 seconds!\n\n## Description\n\n- Default port: `80`\n- Default path: `/postreceive`\n- Default event type: `push`\n\n## Examples\n\nBasic:\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/url\"\n\n\t\"github.com/google/go-github/v69/github\"\n\tghw \"github.com/ldez/ghwebhook/v4\"\n)\n\nfunc main() {\n\teventHandlers := ghw.NewEventHandlers().\n\t\tOnIssuesEvent(func(uri *url.URL, deliveryID string, event *github.IssuesEvent) {\n\t\t\tgo func() {\n\t\t\t\tlog.Println(uri, deliveryID, event.GetAction(), event.Issue)\n\t\t\t}()\n\t\t}).\n\t\tOnPullRequestEvent(func(uri *url.URL, deliveryID string, event *github.PullRequestEvent) {\n\t\t\tlog.Println(uri, deliveryID, event.GetAction(), event.GetNumber(), event.PullRequest)\n\t\t})\n\n\twebHook := ghw.NewWebHook(eventHandlers, ghw.WithAllEventTypes)\n\n\terr := webHook.ListenAndServe()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n\nSecured WebHook with custom port and path:\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/url\"\n\n\t\"github.com/google/go-github/v69/github\"\n\tghw \"github.com/ldez/ghwebhook/v4\"\n\t\"github.com/ldez/ghwebhook/v4/eventtype\"\n)\n\nfunc main() {\n\teventHandlers := ghw.NewEventHandlers().\n\t\tOnIssuesEvent(func(uri *url.URL, deliveryID string, event *github.IssuesEvent) {\n\t\t\tgo func() {\n\t\t\t\tlog.Println(uri, deliveryID, event.GetAction(), event.Issue)\n\t\t\t}()\n\t\t}).\n\t\tOnPullRequestEvent(func(uri *url.URL, deliveryID string, event *github.PullRequestEvent) {\n\t\t\tlog.Println(uri, deliveryID, event.GetAction(), event.GetNumber(), event.PullRequest)\n\t\t})\n\n\twebhook := ghw.NewWebHook(\n\t\teventHandlers,\n\t\tghw.WithPort(5000),\n\t\tghw.WithPath(\"/github\"),\n\t\tghw.WithSecret(\"SECRET\"),\n\t\tghw.Debug,\n\t\tghw.WithEventTypes(eventtype.Issues, eventtype.PullRequest))\n\n\terr := webhook.ListenAndServe()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n\n## References\n\n- https://docs.github.com/en/developers/webhooks-and-events/webhooks/about-webhooks\n- https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks\n- https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads\n","funding_links":["https://github.com/sponsors/ldez","https://ko-fi.com/ldez_oss","https://liberapay.com/ldez","https://thanks.dev/u/gh/ldez"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldez%2Fghwebhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fldez%2Fghwebhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldez%2Fghwebhook/lists"}