{"id":15641376,"url":"https://github.com/cbrgm/githubevents","last_synced_at":"2026-03-02T13:24:41.216Z","repository":{"id":38247709,"uuid":"485061306","full_name":"cbrgm/githubevents","owner":"cbrgm","description":"GitHub webhook events toolset for Go :rocket:","archived":false,"fork":false,"pushed_at":"2025-03-25T13:50:03.000Z","size":1363,"stargazers_count":80,"open_issues_count":2,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-30T03:03:01.211Z","etag":null,"topics":["codegen","events","github","go","go-library","golang","module","webhook","webhooks"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/cbrgm/githubevents#section-readme","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/cbrgm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"chrisbargmann"}},"created_at":"2022-04-24T15:13:14.000Z","updated_at":"2025-03-25T13:50:06.000Z","dependencies_parsed_at":"2023-11-08T13:39:54.285Z","dependency_job_id":"62569f93-ee6c-4412-b56a-4bc529386a88","html_url":"https://github.com/cbrgm/githubevents","commit_stats":{"total_commits":133,"total_committers":6,"mean_commits":"22.166666666666668","dds":"0.49624060150375937","last_synced_commit":"e882ee44425b5c40e9f26867f26166729981b802"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbrgm%2Fgithubevents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbrgm%2Fgithubevents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbrgm%2Fgithubevents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbrgm%2Fgithubevents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cbrgm","download_url":"https://codeload.github.com/cbrgm/githubevents/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247430865,"owners_count":20937874,"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":["codegen","events","github","go","go-library","golang","module","webhook","webhooks"],"created_at":"2024-10-03T11:42:23.027Z","updated_at":"2026-03-02T13:24:41.200Z","avatar_url":"https://github.com/cbrgm.png","language":"Go","readme":"# githubevents\n\n\u003cimg src=\".img/gopher.png\" width=\"150px\" align=\"right\" /\u003e\n\n**[GitHub](https://github.com/) webhook events toolset for [Go](https://go.dev/)**\n\n[![release](https://img.shields.io/github/release-pre/cbrgm/githubevents.svg)](https://github.com/cbrgm/githubevents/releases)\n[![Go Report Card](https://goreportcard.com/badge/github.com/cbrgm/githubevents)](https://goreportcard.com/report/github.com/cbrgm/githubevents)\n[![license](https://img.shields.io/badge/Coverage-88.3%25-green.svg)](https://pkg.go.dev/github.com/cbrgm/githubevents/githubevents)\n[![license](https://img.shields.io/badge/Docs-pkg.go.dev-blue.svg)](https://pkg.go.dev/github.com/cbrgm/githubevents/githubevents)\n[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/cbrgm/githubevents/blob/master/LICENSE)\n![GitHub stars](https://img.shields.io/github/stars/cbrgm/githubevents.svg?label=github%20stars)\n\n`githubevents` is a webhook events toolset for the Go programming language inspired by ***[octokit/webhooks.js](https://github.com/octokit/webhooks.js)***.\n\nThis library makes use of [google/go-github](https://github.com/google/go-github) and provides functionality to register callbacks for Github events and their actions, so that you can easily execute your own logic in response to webhook events.\n\n---\n\n* [Usage](#usage)\n* [API](#api)\n  + [Constructor](#constructor)\n  + [Callbacks](#callbacks)\n  + [OnBeforeAny](#onbeforeany)\n  + [OnAfterAny](#onafterany)\n  + [OnError](#onerror)\n* [Supported Webhooks Events](#supported-webhooks-events)\n* [Local Development](#local-development)\n* [Compatibility](#compatibility)\n* [Contributing \u0026 License](#contributing---license)\n\n## GitHub Events V2 Released - Breaking Changes\n\nV2 of `githubevents` has been released and introduces breaking changes that require refactoring to upgrade:\n\n- The import path has changed and is now: `github.com/cbrgm/githubevents/v2/githubevents`\n- `context.Context` has been added as the first argument to callback functions. Existing callbacks must be updated to accommodate this change.\n\nPlease ensure you update your import statements and refactor callback function signatures accordingly.\n\n## Usage\n\n```go\nimport (\n    \"github.com/cbrgm/githubevents/v2/githubevents\"\n)\n```\n\nCreate a new `githubevents.EventHandler`, register callbacks and start a http server.\n\n```go\npackage main\n\nimport (\n  \"context\"\n  \"fmt\"\n  \"github.com/cbrgm/githubevents/v2/githubevents\"\n  \"github.com/google/go-github/v84/github\"\n  \"net/http\"\n)\n\nfunc main() {\n    // create a new event handler\n    handle := githubevents.New(\"secretkey\")\n\n    // add callbacks\n    handle.OnIssueCommentCreated(\n      func(ctx context.Context, deliveryID string, eventName string, event *github.IssueCommentEvent) error {\n          fmt.Printf(\"%s made a comment!\", event.Sender.Login)\n          return nil\n      },\n    )\n\n    // add a http handleFunc\n    http.HandleFunc(\"/hook\", func(w http.ResponseWriter, r *http.Request) {\n        err := handle.HandleEventRequest(r)\n        if err != nil {\n            fmt.Println(\"error\")\n        }\n    })\n\n    // start the server listening on port 8080\n    if err := http.ListenAndServe(\":8080\", nil); err != nil {\n        panic(err)\n    }\n}\n```\n\nFor more usage examples, please have a look at the [examples](https://github.com/cbrgm/githubevents/tree/main/examples) directory.\n\n## API\n\nPlease refer to [pkg.go.dev](https://pkg.go.dev/github.com/cbrgm/githubevents/githubevents) for a full list of supported callback functions.\n\n### Constructor\n\nTo create a new `githubevents.EventHandler` use the following constructor:\n\n```go\nhandle := githubevents.New(\"secretkey\")\n// ...\n```\n\n`secretkey` is the GitHub Webhook secret token. If your webhook does not contain a secret token, you can set `nil`.\nThis is intended for local development purposes only and all webhooks should ideally set up a secret token.\n\n### Callbacks\n\nFunctions to register callbacks follow a specific naming scheme. `On...` functions register one or more callbacks and add them to previously registered ones.\n\n`SetOn...` functions also register callbacks, but override previously registered ones.\n\n`On...Any`/`SetOn...Any` functions register callbacks that are executed on each action of an event (if the event has actions).\n\nA full list of supported events for this Go module can be found under the section \"[Supported Webhooks Events](#supported-webhooks-events)\". A full documentation including all functions to register callbacks can be found on [pkg.go.dev](https://pkg.go.dev/github.com/cbrgm/githubevents/githubevents).\n\n#### Callback Execution Order\n\n![execution_order](.img/callbacks.png)\n\nEach callback in a registered group is executed in parallel. Each group blocks until all callbacks executed in parallel have returned,\nthen returns the first non-nil error (if any) from them. If `OnError` callbacks have been set, they will be called when an error occurs.\nThe order of execution is open for discussion, contributions are welcome!\n\n### OnBeforeAny\n\n`OnBeforeAny` registers callbacks which are triggered before any event. Registered callbacks are executed in parallel in separate Goroutines.\n\n```go\nhandle := githubevents.New(\"secretkey\")\nhandle.OnBeforeAny(\n    func(ctx context.Context, deliveryID string, eventName string, event interface{}) error {\n        fmt.Printf(\"%s event received!\", eventName)\n        // do something\n        return nil\n    },\n)\n// ...\n```\n\n### OnAfterAny\n\n`OnAfterAny` registers callbacks which are triggered after any event. Registered callbacks are executed in parallel in separate Goroutines.\n\n```go\nhandle := githubevents.New(\"secretkey\")\nhandle.OnAfterAny(\n    func(ctx context.Context, deliveryID string, eventName string, event interface{}) error {\n        fmt.Printf(\"%s event received!\", eventName)\n        // do something\n        return nil\n    },\n)\n// ...\n```\n\n### OnError\n\n`OnError` registers callbacks which are triggered whenever an error occurs. These callbacks can be used for additional error handling, debugging or logging purposes. Registered callbacks are executed in parallel in separate Goroutines.\n\n```go\nhandle := githubevents.New(\"secretkey\")\nhandle.OnError(\n\tfunc(ctx context.Context, deliveryID string, eventName string, event interface{}, err error) error {\n\t\tfmt.Printf(\"received error %s\", err)\n\t\t// additional error handling ...\n\t\treturn err\n\t},\n)\n// ...\n```\n\n## Supported Webhooks Events\n\n\n\n* ***[branch_protection_rule](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch_protection_rule)***\n\n* ***[check_run](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#check_run)***\n\n* ***[check_suite](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#check_suite)***\n\n* ***[commit_comment](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#commit_comment)***\n\n* ***[create](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#create)***\n\n* ***[delete](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#delete)***\n\n* ***[deploy_key](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deploy_key)***\n\n* ***[deployment](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment)***\n\n* ***[deployment_status](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment_status)***\n\n* ***[discussion](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion)***\n\n* ***[fork](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#fork)***\n\n* ***[github_app_authorization](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#github_app_authorization)***\n\n* ***[gollum](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#gollum)***\n\n* ***[installation](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation)***\n\n* ***[installation_repositories](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation_repositories)***\n\n* ***[issue_comment](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issue_comment)***\n\n* ***[issues](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issues)***\n\n* ***[label](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#label)***\n\n* ***[marketplace_purchase](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#marketplace_purchase)***\n\n* ***[member](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#member)***\n\n* ***[membership](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#membership)***\n\n* ***[meta](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#meta)***\n\n* ***[milestone](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#milestone)***\n\n* ***[organization](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#organization)***\n\n* ***[org_block](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#org_block)***\n\n* ***[package](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#package)***\n\n* ***[page_build](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#page_build)***\n\n* ***[ping](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#ping)***\n\n* ***[project_v2](https://docs.github.com/en/webhooks/webhook-events-and-payloads#projects_v2)***\n\n* ***[projects_v2_item](https://docs.github.com/en/webhooks/webhook-events-and-payloads#projects_v2_item)***\n\n* ***[public](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#public)***\n\n* ***[pull_request](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request)***\n\n* ***[pull_request_review](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request_review)***\n\n* ***[pull_request_review_comment](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request_review_comment)***\n\n* ***[push](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push)***\n\n* ***[release](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#release)***\n\n* ***[repository_dispatch](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_dispatch)***\n\n* ***[repository](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository)***\n\n* ***[repository_ruleset](https://docs.github.com/en/webhooks/webhook-events-and-payloads#repository_ruleset)***\n\n* ***[repository_vulnerability_alert](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_vulnerability_alert)***\n\n* ***[star](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#star)***\n\n* ***[status](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#status)***\n\n* ***[team](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#team)***\n\n* ***[team_add](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#team_add)***\n\n* ***[watch](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#watch)***\n\n* ***[workflow_job](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_job)***\n\n* ***[workflow_dispatch](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_dispatch)***\n\n* ***[workflow_run](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_run)***\n\n## Local development\n\nAll Go code in `githubevents` is generated via the make target `make generate` (Go 1.18+ required).\nChanges must be done in `gen/generate.go`. To add new events, add a corresponding entry to `gen/template_params.go`.\n\nTo validate the generated go code run `go run examples/simple-http-server` and make changes to test your functions.\n\nYou can use services like [ngrok](https://ngrok.com/) to expose your local port `8080` to the world.\nEnter the public domain name as the webhook endpoint. You can install webhooks on an organization or on a specific repository.\nTo set up a webhook, go to the settings page of your repository or organization. From there, click Webhooks, then Add webhook.\nAlternatively, you can choose to build and manage a webhook through the Webhooks API.\n\n## Compatibility\n\n| google/go-github | cbrgm/githubevents |\n|------------------|--------------------|\n| `v84.x`            | `v2.14.x`   |\n| `v83.x`            | `v2.13.x`   |\n| `v82.x`            | `v2.12.x`   |\n| `v81.x`            | `v2.11.x`   |\n| `v80.x`            | `v2.10.x`   |\n| `v79.x`            | `v2.9.x`   |\n| `v76.x`            | `v2.8.x`   |\n| `v75.x`            | `v2.7.x`   |\n| `v74.x`            | `v2.6.x`   |\n| `v73.x`            | `v2.5.x`   |\n| `v72.x`            | `v2.4.x`   |\n| `v71.x`            | `v2.3.x`   |\n| `v70.x`            | `v2.0.x`   |\n| `v69.x`            | `v1.22.x`   |\n| `v68.x`            | `v1.21.x`   |\n| `v67.x`            | `v1.20.x`   |\n| `v66.x`            | `v1.19.x`   |\n| `v65.x`            | `v1.18.x`   |\n| `v64.x`            | `v1.17.x`   |\n| `v63.x`            | `v1.16.x`   |\n| `v62.x`            | `v1.15.x`   |\n| `v61.x`            | `v1.14.x`   |\n| `v60.x`            | `v1.13.x`   |\n| `v59.x`            | `v1.12.x`   |\n| `v58.x`            | `v1.10.x`   |\n| `v56.x`            | `v1.9.x`   |\n| `v50.x`            | `v1.8.x`   |\n| `v49.x`            | `v1.7.x`   |\n| `v48.x`            | `v1.6.x`   |\n| `v47.x`            | `v1.4.x`   |\n| `v46.x`            | `v1.3.x`   |\n| `v45.x`            | `v1.2.x`   |\n| `v44.x`            | `v1.1.2x`   |\n| `v43.x`            | `v1.1.1x`   |\n\n## Contributing \u0026 License\n\nWe welcome and value your contributions to this project! 👍 If you're interested in making improvements or adding features, please refer to our [Contributing Guide](https://github.com/cbrgm/githubevents/blob/main/CONTRIBUTING.md). This guide provides comprehensive instructions on how to submit changes, set up your development environment, and more.\n\nPlease note that this project is developed in my spare time and is available for free 🕒💻. As an open-source initiative, it is governed by the [Apache 2.0 License](https://github.com/cbrgm/githubevents/blob/main/LICENSE). This license outlines your rights and obligations when using, modifying, and distributing this software.\n\nYour involvement, whether it's through code contributions, suggestions, or feedback, is crucial for the ongoing improvement and success of this project. Together, we can ensure it remains a useful and well-maintained resource for everyone 🌍.\n","funding_links":["https://ko-fi.com/chrisbargmann"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbrgm%2Fgithubevents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcbrgm%2Fgithubevents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbrgm%2Fgithubevents/lists"}