This repository has been archived on 2024-10-13. You can view files and clone it, but cannot push or open issues or pull requests.
nix-packages/ci/hydra/add-gitea-push-hook.patch
Charlotte 🦝 Delenk 9431fa9030
All checks were successful
Hydra python-simplefuzzyset Hydra build #21466 of nix-packages:aarch64-linux-master-pr75:python-simplefuzzyset
Hydra woodpecker-agent Hydra build #21467 of nix-packages:aarch64-linux-master-pr75:woodpecker-agent
Hydra python-mautrix Hydra build #21468 of nix-packages:aarch64-linux-master-pr75:python-mautrix
Hydra mautrix-discord Hydra build #21469 of nix-packages:aarch64-linux-master-pr75:mautrix-discord
Hydra admin-fe Hydra build #21470 of nix-packages:aarch64-linux-master-pr75:admin-fe
Hydra python-rtf-tokenize Hydra build #21471 of nix-packages:aarch64-linux-master-pr75:python-rtf-tokenize
Hydra woodpecker-frontend Hydra build #21472 of nix-packages:aarch64-linux-master-pr75:woodpecker-frontend
Hydra emoji-volpeon-blobfox-flip Hydra build #21473 of nix-packages:aarch64-linux-master-pr75:emoji-volpeon-blobfox-flip
Hydra papermc Hydra build #21474 of nix-packages:aarch64-linux-master-pr75:papermc
Hydra mautrix-signal Hydra build #21475 of nix-packages:aarch64-linux-master-pr75:mautrix-signal
Hydra emoji-volpeon-bunhd-flip Hydra build #21476 of nix-packages:aarch64-linux-master-pr75:emoji-volpeon-bunhd-flip
Hydra plover-plugin-tapey-tape Hydra build #21477 of nix-packages:aarch64-linux-master-pr75:plover-plugin-tapey-tape
Hydra python-tulir-telethon Hydra build #21478 of nix-packages:aarch64-linux-master-pr75:python-tulir-telethon
Hydra fairfax-hd Hydra build #21479 of nix-packages:aarch64-linux-master-pr75:fairfax-hd
Hydra alco-sans Hydra build #21480 of nix-packages:aarch64-linux-master-pr75:alco-sans
Hydra plover Hydra build #21481 of nix-packages:aarch64-linux-master-pr75:plover
Hydra mautrix-whatsapp Hydra build #21482 of nix-packages:aarch64-linux-master-pr75:mautrix-whatsapp
Hydra plover-plugin-rkb1-hid Hydra build #21483 of nix-packages:aarch64-linux-master-pr75:plover-plugin-rkb1-hid
Hydra plover-plugins-manager Hydra build #21484 of nix-packages:aarch64-linux-master-pr75:plover-plugins-manager
Hydra emoji-volpeon-vlpn Hydra build #21485 of nix-packages:aarch64-linux-master-pr75:emoji-volpeon-vlpn
Hydra python-plover-stroke Hydra build #21486 of nix-packages:aarch64-linux-master-pr75:python-plover-stroke
Hydra matrix-media-repo Hydra build #21487 of nix-packages:aarch64-linux-master-pr75:matrix-media-repo
Hydra woodpecker-server Hydra build #21488 of nix-packages:aarch64-linux-master-pr75:woodpecker-server
Hydra emoji-volpeon-raccoon Hydra build #21489 of nix-packages:aarch64-linux-master-pr75:emoji-volpeon-raccoon
Hydra emoji-volpeon-gphn Hydra build #21490 of nix-packages:aarch64-linux-master-pr75:emoji-volpeon-gphn
Hydra pleroma-fe Hydra build #21491 of nix-packages:aarch64-linux-master-pr75:pleroma-fe
Hydra woodpecker-cli Hydra build #21492 of nix-packages:aarch64-linux-master-pr75:woodpecker-cli
Hydra emoji-volpeon-bunhd Hydra build #21493 of nix-packages:aarch64-linux-master-pr75:emoji-volpeon-bunhd
Hydra python-instagram Hydra build #21494 of nix-packages:aarch64-linux-master-pr75:python-instagram
Hydra attic-server Hydra build #21495 of nix-packages:aarch64-linux-master-pr75:attic-server
Hydra plover-plugin-machine-hid Hydra build #21496 of nix-packages:aarch64-linux-master-pr75:plover-plugin-machine-hid
Hydra miifox-net Hydra build #21497 of nix-packages:aarch64-linux-master-pr75:miifox-net
Hydra plover-dict-didoesdigital Hydra build #21498 of nix-packages:aarch64-linux-master-pr75:plover-dict-didoesdigital
Hydra kreative-square Hydra build #21499 of nix-packages:aarch64-linux-master-pr75:kreative-square
Hydra lotte-art Hydra build #21500 of nix-packages:aarch64-linux-master-pr75:lotte-art
Hydra emoji-volpeon-fox Hydra build #21501 of nix-packages:aarch64-linux-master-pr75:emoji-volpeon-fox
Hydra fairfax Hydra build #21502 of nix-packages:aarch64-linux-master-pr75:fairfax
Hydra akkoma Hydra build #21503 of nix-packages:aarch64-linux-master-pr75:akkoma
Hydra emoji-caro Hydra build #21504 of nix-packages:aarch64-linux-master-pr75:emoji-caro
Hydra mautrix-cleanup Hydra build #21505 of nix-packages:aarch64-linux-master-pr75:mautrix-cleanup
Hydra mautrix-telegram Hydra build #21506 of nix-packages:aarch64-linux-master-pr75:mautrix-telegram
Hydra element-web Hydra build #21507 of nix-packages:aarch64-linux-master-pr75:element-web
Hydra plover-plugin-emoji Hydra build #21508 of nix-packages:aarch64-linux-master-pr75:plover-plugin-emoji
Hydra emoji-lotte Hydra build #21509 of nix-packages:aarch64-linux-master-pr75:emoji-lotte
Hydra emoji-volpeon-drgn Hydra build #21510 of nix-packages:aarch64-linux-master-pr75:emoji-volpeon-drgn
Hydra attic Hydra build #21511 of nix-packages:aarch64-linux-master-pr75:attic
Hydra nasin-nanpa Hydra build #21512 of nix-packages:aarch64-linux-master-pr75:nasin-nanpa
Hydra plover-plugin-yaml-dictionary Hydra build #21513 of nix-packages:aarch64-linux-master-pr75:plover-plugin-yaml-dictionary
Hydra attic-client Hydra build #21514 of nix-packages:aarch64-linux-master-pr75:attic-client
Hydra emoji-volpeon-blobfox Hydra build #21515 of nix-packages:aarch64-linux-master-pr75:emoji-volpeon-blobfox
Hydra constructium Hydra build #21516 of nix-packages:aarch64-linux-master-pr75:constructium
add hydra
2023-04-22 07:59:53 +01:00

84 lines
3.5 KiB
Diff

diff --git a/doc/manual/src/webhooks.md b/doc/manual/src/webhooks.md
index 2b26cd61..674e1064 100644
--- a/doc/manual/src/webhooks.md
+++ b/doc/manual/src/webhooks.md
@@ -1,9 +1,12 @@
# Webhooks
-Hydra can be notified by github's webhook to trigger a new evaluation when a
+Hydra can be notified by github or gitea with webhooks to trigger a new evaluation when a
jobset has a github repo in its input.
-To set up a github webhook go to `https://github.com/<yourhandle>/<yourrepo>/settings` and in the `Webhooks` tab
-click on `Add webhook`.
+
+## GitHub
+
+To set up a webhook for a GitHub repository go to `https://github.com/<yourhandle>/<yourrepo>/settings`
+and in the `Webhooks` tab click on `Add webhook`.
- In `Payload URL` fill in `https://<your-hydra-domain>/api/push-github`.
- In `Content type` switch to `application/json`.
@@ -11,3 +14,14 @@ click on `Add webhook`.
- For `Which events would you like to trigger this webhook?` keep the default option for events on `Just the push event.`.
Then add the hook with `Add webhook`.
+
+## Gitea
+
+To set up a webhook for a Gitea repository go to the settings of the repository in your Gitea instance
+and in the `Webhooks` tab click on `Add Webhook` and choose `Gitea` in the drop down.
+
+- In `Target URL` fill in `https://<your-hydra-domain>/api/push-gitea`.
+- Keep HTTP method `POST`, POST Content Type `application/json` and Trigger On `Push Events`.
+- Change the branch filter to match the git branch hydra builds.
+
+Then add the hook with `Add webhook`.
diff --git a/src/lib/Hydra/Controller/API.pm b/src/lib/Hydra/Controller/API.pm
index 8ebed599..06f35d4b 100644
--- a/src/lib/Hydra/Controller/API.pm
+++ b/src/lib/Hydra/Controller/API.pm
@@ -285,6 +285,23 @@ sub push_github : Chained('api') PathPart('push-github') Args(0) {
$c->response->body("");
}
+sub push_gitea : Chained('api') PathPart('push-gitea') Args(0) {
+ my ($self, $c) = @_;
+
+ $c->{stash}->{json}->{jobsetsTriggered} = [];
+
+ my $in = $c->request->{data};
+ my $url = $in->{repository}->{clone_url} or die;
+ $url =~ s/.git$//;
+ print STDERR "got push from Gitea repository $url\n";
+
+ triggerJobset($self, $c, $_, 0) foreach $c->model('DB::Jobsets')->search(
+ { 'project.enabled' => 1, 'me.enabled' => 1 },
+ { join => 'project'
+ , where => \ [ 'me.flake like ? or exists (select 1 from JobsetInputAlts where project = me.project and jobset = me.name and value like ?)', [ 'flake', "%$url%"], [ 'value', "%$url%" ] ]
+ });
+ $c->response->body("");
+}
1;
diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm
index c6843d29..1b33db2a 100644
--- a/src/lib/Hydra/Controller/Root.pm
+++ b/src/lib/Hydra/Controller/Root.pm
@@ -32,6 +32,7 @@ sub noLoginNeeded {
return $whitelisted ||
$c->request->path eq "api/push-github" ||
+ $c->request->path eq "api/push-gitea" ||
$c->request->path eq "google-login" ||
$c->request->path eq "github-redirect" ||
$c->request->path eq "github-login" ||
@@ -77,7 +78,7 @@ sub begin :Private {
$_->supportedInputTypes($c->stash->{inputTypes}) foreach @{$c->hydra_plugins};
# XSRF protection: require POST requests to have the same origin.
- if ($c->req->method eq "POST" && $c->req->path ne "api/push-github") {
+ if ($c->req->method eq "POST" && $c->req->path ne "api/push-github" && $c->req->path ne "api/push-gitea") {
my $referer = $c->req->header('Referer');
$referer //= $c->req->header('Origin');
my $base = $c->req->base;