-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitLab's integration webhooks support
- Loading branch information
Showing
40 changed files
with
718 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,21 @@ services: | |
build: | ||
context: . | ||
image: packeton/packeton:latest | ||
restart: unless-stopped | ||
container_name: packagist | ||
hostname: packagist | ||
environment: | ||
ADMIN_USER: admin | ||
ADMIN_PASSWORD: 123456 | ||
ADMIN_EMAIL: [email protected] | ||
# ADMIN_USER: admin | ||
# ADMIN_PASSWORD: 123456 | ||
# ADMIN_EMAIL: [email protected] | ||
TRUSTED_PROXIES: 172.16.0.0/12 | ||
# Default SQLite | ||
# DATABASE_URL: "mysql://app:[email protected]:3306/app?serverVersion=8&charset=utf8mb4" | ||
DATABASE_URL: "mysql://app:[email protected]:3306/app?serverVersion=8&charset=utf8mb4" | ||
|
||
# MAILER_DSN: smtp://user:[email protected]:587 | ||
# MAILER_FROM: Packeton <[email protected]> | ||
ports: | ||
# setup nginx reverse proxy for ssl | ||
- '127.0.0.1:8088:80' | ||
volumes: | ||
- .docker:/data |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Packeton\Event; | ||
|
||
use Packeton\Entity\Package; | ||
use Symfony\Contracts\EventDispatcher\Event; | ||
|
||
class PackageEvent extends Event | ||
{ | ||
public const PACKAGE_CREATE = 'packageCreate'; | ||
|
||
public function __construct(protected Package $package) | ||
{ | ||
} | ||
|
||
public function getPackage(): Package | ||
{ | ||
return $this->package; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Packeton\EventListener; | ||
|
||
use Packeton\Event\PackageEvent; | ||
use Packeton\Event\UpdaterEvent; | ||
use Packeton\Integrations\IntegrationRegistry; | ||
use Packeton\Integrations\Model\IntegrationUtils; | ||
use Psr\Log\LoggerInterface; | ||
use Symfony\Component\EventDispatcher\Attribute\AsEventListener; | ||
|
||
class IntegrationListener | ||
{ | ||
public function __construct( | ||
protected IntegrationRegistry $integrations, | ||
protected LoggerInterface $logger | ||
) { | ||
} | ||
|
||
#[AsEventListener(event: 'packageCreate')] | ||
public function onPackageCreate(PackageEvent $event): void | ||
{ | ||
$package = $event->getPackage(); | ||
if (null === ($oauth = $package->getIntegration()) || empty($package->getExternalRef())) { | ||
return; | ||
} | ||
|
||
try { | ||
$app = $this->integrations->findApp($oauth->getAlias()); | ||
$info = $app->addHook($oauth, $package->getExternalRef()); | ||
if ($info['status'] ?? false) { | ||
$package->setAutoUpdated(true); | ||
} | ||
} catch (\Throwable $e) { | ||
$info = ['status' => false, 'error' => IntegrationUtils::castError($e, $app ?? null)]; | ||
} | ||
|
||
$package->setWebhookInfo($info); | ||
} | ||
|
||
#[AsEventListener(event: 'packageRemove')] | ||
public function onPackageDelete(UpdaterEvent $event): void | ||
{ | ||
$package = $event->getPackage(); | ||
if (null === ($oauth = $package->getIntegration()) || empty($package->getExternalRef())) { | ||
return; | ||
} | ||
|
||
try { | ||
$app = $this->integrations->findApp($oauth->getAlias(), false); | ||
$app->removeHook($oauth, $package->getExternalRef()); | ||
} catch (\Throwable $e) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.