{"id":29281220,"url":"https://github.com/prajithp/github-app","last_synced_at":"2025-07-05T16:42:09.885Z","repository":{"id":300739462,"uuid":"1002746824","full_name":"Prajithp/github-app","owner":"Prajithp","description":"framework for building GitHub Apps ","archived":false,"fork":false,"pushed_at":"2025-06-16T14:31:51.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-23T11:01:38.499Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Prajithp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-06-16T04:44:07.000Z","updated_at":"2025-06-16T14:31:54.000Z","dependencies_parsed_at":"2025-06-23T11:01:51.134Z","dependency_job_id":"3d490cd3-e441-417a-9561-406dca9ab250","html_url":"https://github.com/Prajithp/github-app","commit_stats":null,"previous_names":["prajithp/github-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Prajithp/github-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prajithp%2Fgithub-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prajithp%2Fgithub-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prajithp%2Fgithub-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prajithp%2Fgithub-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Prajithp","download_url":"https://codeload.github.com/Prajithp/github-app/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prajithp%2Fgithub-app/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263773364,"owners_count":23509225,"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":[],"created_at":"2025-07-05T16:42:06.708Z","updated_at":"2025-07-05T16:42:09.879Z","avatar_url":"https://github.com/Prajithp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub App Framework \n\nA robust Go framework for building GitHub Apps with webhook handling, configuration management, and utilities for interacting with the GitHub API. This is a wrapper around the [palantir/go-githubapp](https://github.com/palantir/go-githubapp) library.\n\n## Installation\n\n```bash\ngo get github.com/Prajithp/github-app\n```\n\n## Quick Start\n\n### 1. Create a Configuration File\n\nCreate a `config.yaml` file:\n\n```yaml\nserver:\n  address: \"0.0.0.0\"\n  port: 8080\n  max_queue_size: 1000\n  max_workers: 50\n  route: \"/api/webhooks/github\"\n\ngithub:\n  web_url: \"https://github.com\"\n  v3_api_url: \"https://api.github.com\"\n  v4_api_url: \"https://api.github.com/graphql\"\n  app:\n    integration_id: 123456  # Your GitHub App ID\n    webhook_secret: \"your-webhook-secret\"\n    private_key: |\n      -----BEGIN RSA PRIVATE KEY-----\n      YOUR_PRIVATE_KEY_HERE\n      -----END RSA PRIVATE KEY-----\n```\n\n### 2. Create an Event Handler\n\n```go\npackage handlers\n\nimport (\n    \"context\"\n    \"github.com/Prajithp/github-app/utils\"\n    \"github.com/google/go-github/v72/github\"\n    \"github.com/rs/zerolog/log\"\n)\n\ntype PullRequestHandler struct{}\n\nfunc (h *PullRequestHandler) Handles() []string {\n    return []string{\"pull_request\"}\n}\n\nfunc (h *PullRequestHandler) Handle(ctx context.Context, eventType, deliveryID string, payload []byte) error {\n    event, err := utils.ParseEvent[github.PullRequestEvent](payload)\n    if err != nil {\n        return err\n    }\n\n    log.Info().\n        Str(\"action\", event.GetAction()).\n        Str(\"pr_number\", fmt.Sprintf(\"%d\", event.GetPullRequest().GetNumber())).\n        Str(\"repo\", event.GetRepo().GetFullName()).\n        Msg(\"Handling pull request event\")\n\n    // Your logic here\n    return nil\n}\n```\n\n### 3. Create the Main Application\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"os\"\n    \"os/signal\"\n    \"syscall\"\n\n    \"github.com/Prajithp/github-app/config\"\n    \"github.com/Prajithp/github-app/server\"\n    \"github.com/Prajithp/github-app/utils\"\n    \"github.com/palantir/go-githubapp/githubapp\"\n    \"github.com/rs/zerolog\"\n    \"github.com/rs/zerolog/log\"\n)\n\nfunc main() {\n    // Setup logging\n    utils.SetupLogger(\"my-github-app\", \"1.0.0\", zerolog.InfoLevel)\n\n    // Load configuration\n    cfg, err := utils.ReadConfig[config.Config](\"config.yaml\", \"GITHUB_APP\")\n    if err != nil {\n        log.Fatal().Err(err).Msg(\"Failed to load configuration\")\n    }\n\n    // Create GitHub client creator\n    cc, err := githubapp.NewDefaultCachingClientCreator(\n        githubapp.Config{\n            V3APIURL: cfg.Github.V3APIURL,\n            V4APIURL: cfg.Github.V4APIURL,\n            App: githubapp.App{\n                IntegrationID: cfg.Github.App.IntegrationID,\n                WebhookSecret: cfg.Github.App.WebhookSecret,\n                PrivateKey:    cfg.Github.App.PrivateKey,\n            },\n        },\n    )\n    if err != nil {\n        log.Fatal().Err(err).Msg(\"Failed to create client creator\")\n    }\n\n    // Create server with handlers\n    srv, err := server.New(\n        \u0026cfg,\n        server.WithClientCreator(cc),\n        server.WithEventHandlers(\n            \u0026handlers.PullRequestHandler{},\n            // Add more handlers here\n        ),\n    )\n    if err != nil {\n        log.Fatal().Err(err).Msg(\"Failed to create server\")\n    }\n\n    // Start server\n    ctx, cancel := context.WithCancel(context.Background())\n    defer cancel()\n\n    if err := srv.Start(ctx); err != nil {\n        log.Fatal().Err(err).Msg(\"Server failed to start\")\n    }\n}\n```\n\n## Configuration\n\n### Environment Variables\n\nAll configuration values can be overridden using environment variables:\n\n| Config Path | Environment Variable | Default |\n|------------|---------------------|---------|\n| `server.address` | `GITHUB_APP_SERVER_ADDRESS` or `SERVER_ADDRESS` | `0.0.0.0` |\n| `server.port` | `GITHUB_APP_SERVER_PORT` or `SERVER_PORT` | `8080` |\n| `server.max_workers` | `GITHUB_APP_MAX_WORKERS` or `MAX_WORKERS` | `50` |\n| `server.max_queue_size` | `GITHUB_APP_MAX_QUEUE_SIZE` or `MAX_QUEUE_SIZE` | `1000` |\n| `server.route` | `GITHUB_APP_SERVER_ROUTE` or `SERVER_ROUTE` | `/api/webhooks/github` |\n| `github.app.integration_id` | `GITHUB_APP_ID` | - |\n| `github.app.webhook_secret` | `GITHUB_WEBHOOK_SECRET` | - |\n| `github.app.private_key` | `GITHUB_PRIVATE_KEY` | - |\n| `github.web_url` | `GITHUB_WEB_URL` | `https://github.com` |\n| `github.v3_api_url` | `GITHUB_V3_API_URL` | `https://api.github.com` |\n| `github.v4_api_url` | `GITHUB_V4_API_URL` | `https://api.github.com/graphql` |\n\n## Advanced Usage\n\n### Loading Repository Configuration\n\nThe framework supports loading app-specific configuration from repositories:\n\n```go\n// Define your repository config structure\ntype RepoConfig struct {\n    Enabled  bool     `yaml:\"enabled\"`\n    Features []string `yaml:\"features\"`\n    Settings map[string]interface{} `yaml:\"settings\"`\n}\n\n// Create a config loader\nloader := appconfig.NewLoader(\n    appconfig.WithOwner(\"myorg\"),\n    appconfig.WithRepo(\"myrepo\"),\n)\n\nconfigLoader := utils.NewAppConfigLoader[RepoConfig](\n    utils.WithAppConfigLoader[RepoConfig](loader),\n)\n\n// Load config from repository\nrepoConfig, err := configLoader.LoadRepositoryConfig(\n    ctx, \n    githubClient, \n    \"owner\", \n    \"repo\", \n    \"main\", // branch\n)\n```\n\n## Acknowledgments\n\n- Built on top of [palantir/go-githubapp](https://github.com/palantir/go-githubapp)\n- Uses [google/go-github](https://github.com/google/go-github) for GitHub API interactions\n- Logging powered by [rs/zerolog](https://github.com/rs/zerolog)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprajithp%2Fgithub-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprajithp%2Fgithub-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprajithp%2Fgithub-app/lists"}