Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Fix manual Git webhook generation

Andras Bacsaie4b21959325f
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php
index 1abb90ce5c..a11e857cef 100644
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@ -511,6 +511,9 @@ function generateDeployWebhook($resource)
return $url;
}
function generateGitManualWebhook($resource, $type) {
+ if ($resource->source_id !== 0) {
+ return null;
+ }
if ($resource->getMorphClass() === 'App\Models\Application') {
$baseUrl = base_url();
$api = Url::fromString($baseUrl) . "/webhooks/source/$type/events/manual";
diff --git a/resources/views/livewire/project/shared/webhooks.blade.php b/resources/views/livewire/project/shared/webhooks.blade.php
index 243b5dea33..c77ae33153 100644
--- a/resources/views/livewire/project/shared/webhooks.blade.php
+++ b/resources/views/livewire/project/shared/webhooks.blade.php
@@ -11,27 +11,31 @@
</div>
<div>
<h3>Manual Git Webhooks</h3>
- <form wire:submit.prevent='saveSecret' class="flex flex-col gap-2">
- <div class="flex items-end gap-2">
- <x-forms.input helper="Content Type in GitHub configuration could be json or form-urlencoded." readonly
- label="GitHub" id="githubManualWebhook"></x-forms.input>
- <x-forms.input type="password"
- helper="Need to set a secret to be able to use this webhook. It should match with the secret in GitHub."
- label="GitHub Webhook Secret" id="resource.manual_webhook_secret_github"></x-forms.input>
+ @if ($githubManualWebhook && $gitlabManualWebhook)
+ <form wire:submit.prevent='saveSecret' class="flex flex-col gap-2">
+ <div class="flex items-end gap-2">
+ <x-forms.input helper="Content Type in GitHub configuration could be json or form-urlencoded."
+ readonly label="GitHub" id="githubManualWebhook"></x-forms.input>
+ <x-forms.input type="password"
+ helper="Need to set a secret to be able to use this webhook. It should match with the secret in GitHub."
+ label="GitHub Webhook Secret" id="resource.manual_webhook_secret_github"></x-forms.input>
- </div>
- <a target="_blank" class="flex hover:no-underline" href="{{ $resource?->gitWebhook }}">
- <x-forms.button>Webhook Configuration on GitHub
- <x-external-link />
- </x-forms.button>
- </a>
- <div class="flex gap-2">
- <x-forms.input readonly label="GitLab" id="gitlabManualWebhook"></x-forms.input>
- <x-forms.input type="password"
- helper="Need to set a secret to be able to use this webhook. It should match with the secret in GitLab."
- label="GitLab Webhook Secret" id="resource.manual_webhook_secret_gitlab"></x-forms.input>
- </div>
- <x-forms.button type="submit">Save</x-forms.button>
- </form>
+ </div>
+ <a target="_blank" class="flex hover:no-underline" href="{{ $resource?->gitWebhook }}">
+ <x-forms.button>Webhook Configuration on GitHub
+ <x-external-link />
+ </x-forms.button>
+ </a>
+ <div class="flex gap-2">
+ <x-forms.input readonly label="GitLab" id="gitlabManualWebhook"></x-forms.input>
+ <x-forms.input type="password"
+ helper="Need to set a secret to be able to use this webhook. It should match with the secret in GitLab."
+ label="GitLab Webhook Secret" id="resource.manual_webhook_secret_gitlab"></x-forms.input>
+ </div>
+ <x-forms.button type="submit">Save</x-forms.button>
+ </form>
+ @else
+ You are using an official Git App. You do not need manual webhooks.
+ @endif
</div>
</div>