{"id":27378015,"url":"https://github.com/ren3gadem4rm0t/github-hook-types-go","last_synced_at":"2025-04-13T13:32:48.979Z","repository":{"id":287344144,"uuid":"964132514","full_name":"ren3gadem4rm0t/github-hook-types-go","owner":"ren3gadem4rm0t","description":"A comprehensive Go library providing strongly-typed definitions for all GitHub webhook events and payloads. This library helps developers build applications that receive and process GitHub webhook events with proper type safety and full IntelliSense support.","archived":false,"fork":false,"pushed_at":"2025-04-11T00:34:18.000Z","size":109,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T09:53:12.373Z","etag":null,"topics":["github-api","go","golang","webhooks"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ren3gadem4rm0t.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2025-04-10T18:31:08.000Z","updated_at":"2025-04-11T01:02:27.000Z","dependencies_parsed_at":"2025-04-11T09:53:46.850Z","dependency_job_id":"61a7681a-26a6-48ee-8a6b-4a878ca995e9","html_url":"https://github.com/ren3gadem4rm0t/github-hook-types-go","commit_stats":null,"previous_names":["ren3gadem4rm0t/github-hook-types-go"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ren3gadem4rm0t%2Fgithub-hook-types-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ren3gadem4rm0t%2Fgithub-hook-types-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ren3gadem4rm0t%2Fgithub-hook-types-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ren3gadem4rm0t%2Fgithub-hook-types-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ren3gadem4rm0t","download_url":"https://codeload.github.com/ren3gadem4rm0t/github-hook-types-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248721152,"owners_count":21151054,"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-api","go","golang","webhooks"],"created_at":"2025-04-13T13:31:51.874Z","updated_at":"2025-04-13T13:32:48.960Z","avatar_url":"https://github.com/ren3gadem4rm0t.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Build Status](https://github.com/ren3gadem4rm0t/github-hook-types-go/actions/workflows/ci.yml/badge.svg)](https://github.com/ren3gadem4rm0t/github-hook-types-go/actions/workflows/ci.yml)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/ren3gadem4rm0t/github-hook-types-go?sort=semver)](https://github.com/ren3gadem4rm0t/github-hook-types-go/releases)\n[![GitHub issues](https://img.shields.io/github/issues/ren3gadem4rm0t/github-hook-types-go)](https://github.com/ren3gadem4rm0t/github-hook-types-go/issues)\n[![GitHub stars](https://img.shields.io/github/stars/ren3gadem4rm0t/github-hook-types-go?style=social)](https://github.com/ren3gadem4rm0t/github-hook-types-go/stargazers)\n\u003c!-- [![Go Report Card](https://goreportcard.com/badge/github.com/ren3gadem4rm0t/github-hook-types-go)](https://goreportcard.com/report/github.com/ren3gadem4rm0t/github-hook-types-go) --\u003e\n\n# GitHub Webhook Types for Go\n\nA comprehensive Go library providing strongly-typed definitions for all GitHub webhook events and payloads. This library helps developers build applications that receive and process GitHub webhook events with proper type safety and full IntelliSense support.\n\n## Features\n\n- Complete coverage of all GitHub webhook event types\n- Strongly-typed structs for each webhook payload\n- JSON tags for direct unmarshaling of webhook payloads\n- Helper functions for webhook signature validation\n- Simple HTTP handler for webhook processing\n- Detailed documentation for all types and fields\n\n## Installation\n\n```bash\ngo get github.com/ren3gadem4rm0t/github-hook-types-go\n```\n\n## Usage\n\n### Basic Example\n\nHere's a simple example of how to use this library to handle GitHub webhooks:\n\n```go\npackage main\n\nimport (\n \"log\"\n \"net/http\"\n \"os\"\n\n \"github.com/ren3gadem4rm0t/github-hook-types-go\"\n \"github.com/ren3gadem4rm0t/github-hook-types-go/webhook\"\n)\n\nfunc main() {\n // Get webhook secret from environment\n secret := os.Getenv(\"WEBHOOK_SECRET\")\n \n // Create a new webhook handler\n handler := webhook.NewHandler(secret)\n\n // Set up a webhook handler endpoint\n http.HandleFunc(\"/webhook\", handler.HandleWebhook(handleGitHubEvent))\n\n // Start the server\n port := os.Getenv(\"PORT\")\n if port == \"\" {\n  port = \"3000\"\n }\n \n log.Printf(\"Server starting on port %s...\\n\", port)\n log.Fatal(http.ListenAndServe(\":\"+port, nil))\n}\n\n// handleGitHubEvent processes GitHub webhook events\nfunc handleGitHubEvent(event *github.WebhookEvent) error {\n log.Printf(\"Received %s event (Delivery ID: %s)\\n\", event.Type, event.DeliveryID)\n\n // Type switch to handle different event types\n switch event.Type {\n case github.PingEvent:\n  payload := event.Payload.(*github.PingPayload)\n  log.Printf(\"Ping received! Zen: %s\", payload.Zen)\n  \n case github.PushEvent:\n  payload := event.Payload.(*github.PushPayload)\n  log.Printf(\"Push to %s by %s\", \n   payload.Repository.FullName, \n   payload.PusherPerson.Name)\n  \n case github.IssuesEvent:\n  payload := event.Payload.(*github.IssuesPayload)\n  log.Printf(\"Issue #%d %s by %s: %s\",\n   payload.Issue.Number,\n   payload.Action,\n   payload.Issue.User.Login,\n   payload.Issue.Title)\n   \n default:\n  log.Printf(\"Received unhandled event type: %s\", event.Type)\n }\n\n return nil\n}\n```\n\n### Manual Webhook Processing\n\nIf you need more control over the webhook processing flow:\n\n```go\nfunc webhookHandler(w http.ResponseWriter, r *http.Request) {\n // Create a webhook handler with your secret\n handler := webhook.NewHandler(\"your-webhook-secret\")\n \n // Process the webhook\n event, err := handler.ProcessWebhook(r)\n if err != nil {\n  http.Error(w, err.Error(), http.StatusBadRequest)\n  return\n }\n \n // Handle the event based on its type\n switch event.Type {\n case github.PushEvent:\n  payload := event.Payload.(*github.PushPayload)\n  // Process push event...\n case github.IssuesEvent:\n  payload := event.Payload.(*github.IssuesPayload)\n  // Process issues event...\n // Handle other event types...\n }\n \n w.WriteHeader(http.StatusOK)\n}\n```\n\n### Using with Gin Framework\n\nFor applications using the Gin web framework, check out the [Gin webhook example](examples/gin-webhook-server/) which demonstrates:\n\n- Creating logging middleware with Zerolog\n- Setting up webhook signature validation middleware\n- Handling GitHub webhook events in a Gin router\n- Properly parsing and processing webhook payloads\n\n## Supported Event Types\n\nThis library supports all GitHub webhook event types, including:\n\n- `check_run`\n- `check_suite`\n- `commit_comment`\n- `content_reference`\n- `create`\n- `delete`\n- `deploy_key`\n- `deployment`\n- `deployment_status`\n- `discussion`\n- `discussion_comment`\n- `fork`\n- `github_app_authorization`\n- `gollum`\n- `installation`\n- `installation_repositories`\n- `issue_comment`\n- `issues`\n- `label`\n- `marketplace_purchase`\n- `member`\n- `membership`\n- `meta`\n- `milestone`\n- `organization`\n- `org_block`\n- `package`\n- `page_build`\n- `ping`\n- `project`\n- `project_card`\n- `project_column`\n- `public`\n- `pull_request`\n- `pull_request_review`\n- `pull_request_review_comment`\n- `push`\n- `release`\n- `repository_dispatch`\n- `repository`\n- `repository_import`\n- `repository_vulnerability_alert`\n- `security_advisory`\n- `sponsorship`\n- `star`\n- `status`\n- `team`\n- `team_add`\n- `watch`\n- `workflow_dispatch`\n- `workflow_job`\n- `workflow_run`\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fren3gadem4rm0t%2Fgithub-hook-types-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fren3gadem4rm0t%2Fgithub-hook-types-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fren3gadem4rm0t%2Fgithub-hook-types-go/lists"}