repman
repman copied to clipboard
[Feature request] Mass webhook synchronization
Currently only way to synchronize package is via webhook
When packages are created by user without right permissions, packages are created but they will not have webhook set up, and they will not be refreshed automatically.
Solutions would be to add possibility to refresh synchronisation of all webhooks in organization. (Doing this one by one is usually not an option)
I think it relates to https://github.com/repman-io/repman/issues/122
I think the OP means that it would be great if there could be just one hook for the whole organization, so that when it receives a POST with repository data it will update that repository inside the organization. Here's an example of that hook. This works with packeton but packeton is outdated and repman is easier to update to use composer 2, for me:
Right now I have to add each hook for each package. It would be nice if it can be done for the whole organization. Thanks for looking into it.
Currently you can synchronize webhook using "Webhook" page (for given package):
An organization wide webhook and repository discovery will be more difficult to do as each provider sends data in a different form.
Another thing that comes to my mind: you could do an action that synchronizes webhooks for the entire organization - something like that is relatively easy to do (just like above button but with forech
:wink:).
Yes please. Please add the feature that synchronizes webhooks for the entire organization. Then, later, I think, it would be easy enough, for me, to add hooks for each provider, probably depending on the URL, so it can parse the POST to determine the repository to update.
Proof of concept for OrganizationController.php
:
/**
* @Route("/organization/{organization}/{token}/webhook", name="organization_webhook", methods={"GET","POST"}, requirements={"organization"="%organization_pattern%"})
*/
public function organizationWebhook(Organization $organization, string $token, Request $request): Response
{
$validToken = $this->organizationQuery->findToken($organization->id(), $token)
->getOrNull();
if ($validToken)
{
if ($request->isMethod(Request::METHOD_POST))
{
$input = json_decode($request->getContent(), true);
// do matching here depending on host that posts?
if (isset($input['repository']['full_name']))
{
$packageNames = $this->packageQuery->getAllNames($organization->id());
$package = null;
foreach($packageNames as $searchPackage)
if ($searchPackage->name() == $input['repository']['full_name'])
{
$package = $searchPackage;
break;
}
if ($package)
{
$this->dispatchMessage(new SynchronizePackage($package->id()));
$this->addFlash('success', sprintf('Package "%s" will be synchronized in background.', $package->name()));
}
}
}
}
else
$this->addFlash('error', sprintf('Invalid token for %s.', $organization->name()));
return $this->redirectToRoute('organization_tokens', ['organization' => $organization->alias()]);
}
@shemgp would a console command also suffice?
@xvilo It would be better as a web hook for my use case. I'm using Gitea and it's web hook in organization feature so that I don't have to add all the web hooks to each repo under that organization. So far, my fork of repman, with patches, works for my me.
We need this kind of feature too. We are working to migrate around 500 libraries from toran to repman. We use Bitbucket server to manage git repos, and there is no way for automatic setting these webhooks. I was thinking that besides a general webhook for an organisation, it will be great to have the possiblity to set some kind of json path with the json key that stores the actual repo location. This way it will be easier to identify the update package instead of going trough all of them.