MCPcopy Index your code
hub / github.com/rilldata/rill / githubWebhook

Method githubWebhook

admin/server/github.go:913–938  ·  view source on GitHub ↗

githubWebhook is called by Github to deliver events about new pushes, pull requests, changes to a repository, etc. It's implemented as a non-gRPC endpoint mounted directly on /github/webhook. Note that Github webhooks have a timeout of 10 seconds. Webhook processing is moved to the background to pre

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

911// It's implemented as a non-gRPC endpoint mounted directly on /github/webhook.
912// Note that Github webhooks have a timeout of 10 seconds. Webhook processing is moved to the background to prevent timeouts.
913func (s *Server) githubWebhook(w http.ResponseWriter, r *http.Request) {
914 if r.Method != http.MethodPost {
915 http.Error(w, "expected a POST request", http.StatusBadRequest)
916 return
917 }
918
919 payload, err := github.ValidatePayload(r, []byte(s.opts.GithubAppWebhookSecret))
920 if err != nil {
921 http.Error(w, fmt.Sprintf("invalid github payload: %s", err), http.StatusUnauthorized)
922 return
923 }
924
925 event, err := github.ParseWebHook(github.WebHookType(r), payload)
926 if err != nil {
927 http.Error(w, fmt.Sprintf("invalid webhook payload: %s", err), http.StatusBadRequest)
928 return
929 }
930
931 err = s.admin.ProcessGithubEvent(context.Background(), event)
932 if err != nil {
933 http.Error(w, fmt.Sprintf("failed to process event: %s", err), http.StatusBadRequest)
934 return
935 }
936
937 w.WriteHeader(http.StatusOK)
938}
939
940// githubStatus is a http wrapper over [GetGithubRepoStatus]/[GetGithubUserStatus] depending upon whether `remote` query is passed.
941// It redirects to the grantAccessURL if there is no access.

Callers

nothing calls this directly

Calls 3

ProcessGithubEventMethod · 0.80
WriteHeaderMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected