-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically Create Webhook #8
base: main
Are you sure you want to change the base?
Conversation
Unfortunately this doesn't work because there seems to a recently introduced bug go-gitea/gitea#23139 :( |
13fae9d
to
7b00314
Compare
Subdirs are simply named by taking the prefix of the input UUID. This is a common technique to prevent the chance of overflowing filesystem limits on the number of files allowed in a single directory. e.g. Before - /srv/gitea/custom/public/90fa9a89-5e50-4bd4-834d-d42655e1ee8e.html - http://127.0.0.1:3000/assets/90fa9a89-5e50-4bd4-834d-d42655e1ee8e.html After: - /srv/gitea/custom/public/bids-validator/84/b1/84b10e1c-b188-41e2-a92d-fb6ded9c6889.html - http://127.0.0.1:3000/assets/bids-validator/84/b1/84b10e1c-b188-41e2-a92d-fb6ded9c6889.html
0598331
to
adba766
Compare
addr := server.Addr | ||
if addr == "" { | ||
addr = ":http" | ||
} | ||
sock, err := net.Listen("tcp", addr) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Printf("main: listening on %q", bidsHookUrl) | ||
log.Fatal(server.ListenAndServe()) | ||
err = installWebhook() | ||
if err != nil { | ||
log.Fatalf("error installing webhook: %v", err) | ||
} | ||
log.Fatal(server.Serve(sock)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for all this is so that we don't installWebhook
until we know we own addr
. Otherwise we might break an existing webhook.
log.Printf("main: listening on %q", bidsHookUrl) | ||
log.Fatal(server.ListenAndServe()) | ||
err = installWebhook() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err = installWebhook() | |
// to avoid breaking a pre-existing bids-hook only tell Gitea about us once we know we own addr | |
err = installWebhook() |
Actually not: rather this didn't work at all until a month ago; the /admin/hooks API was started two years ago but only got merged recently. The bug is that in those two years things must have shifted around and broken the PR, and they didn't actually test it out. Before then there would simply be no way to automate this deployment, as far as I can tell. We would have had to rewrite everything to do OAuth, or gone back to using Drone, or just settled for giving manual instructions >.<. And this would be true whether we set up the webhook with ansible or with golang. |
Yeah, I had noticed that there was no API for system-level webhooks, and thought we would just give manual instructions for that step. But if/when your upstream PR gets merged and released, we can switch to automatic webhook creation/update. |
Simplify deployment by dropping the need to create a webhook ourselves.