2023-05-09 08:01:57 +00:00
|
|
|
<div x-data="{ deleteSource: false }">
|
|
|
|
<x-naked-modal show="deleteSource" message='Are you sure you would like to delete this source?' />
|
2023-05-08 11:36:49 +00:00
|
|
|
<form wire:submit.prevent='submit'>
|
2023-05-18 11:26:35 +00:00
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
<h1>GitHub App</h1>
|
2023-06-12 20:02:10 +00:00
|
|
|
<div class="flex gap-2">
|
2023-05-18 11:26:35 +00:00
|
|
|
@if ($github_app->app_id)
|
2023-05-25 12:05:44 +00:00
|
|
|
<x-forms.button type="submit">Save</x-forms.button>
|
|
|
|
<x-forms.button x-on:click.prevent="deleteSource = true">
|
2023-05-18 11:26:35 +00:00
|
|
|
Delete
|
2023-05-25 12:05:44 +00:00
|
|
|
</x-forms.button>
|
2023-05-18 11:26:35 +00:00
|
|
|
<a href="{{ $installation_url }}">
|
2023-05-25 12:05:44 +00:00
|
|
|
<x-forms.button>
|
2023-05-18 11:26:35 +00:00
|
|
|
@if ($github_app->installation_id)
|
|
|
|
Update Repositories
|
|
|
|
<x-external-link />
|
|
|
|
@else
|
|
|
|
Install Repositories
|
|
|
|
<x-external-link />
|
|
|
|
@endif
|
2023-05-25 12:05:44 +00:00
|
|
|
</x-forms.button>
|
2023-05-18 11:26:35 +00:00
|
|
|
</a>
|
|
|
|
@else
|
2023-05-25 12:05:44 +00:00
|
|
|
<x-forms.button disabled type="submit">Save</x-forms.button>
|
|
|
|
<x-forms.button x-on:click.prevent="deleteSource = true">
|
2023-05-18 11:26:35 +00:00
|
|
|
Delete
|
2023-05-25 12:05:44 +00:00
|
|
|
</x-forms.button>
|
2023-05-31 20:23:17 +00:00
|
|
|
|
2023-05-18 11:26:35 +00:00
|
|
|
@endif
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-06-12 20:02:10 +00:00
|
|
|
<div class="pt-2 pb-10 text-sm">Your Private GitHub App for private repositories.</div>
|
2023-05-31 20:23:17 +00:00
|
|
|
@if (!$github_app->app_id)
|
2023-06-12 20:02:10 +00:00
|
|
|
<div class="flex items-center gap-4 pt-2 pb-10">
|
|
|
|
<div class="text-sm">You need to register a GitHub App before using this source:</div>
|
2023-05-31 20:23:17 +00:00
|
|
|
<form>
|
2023-06-05 10:07:55 +00:00
|
|
|
<x-forms.button x-on:click.prevent="createGithubApp">Register a GitHub
|
2023-05-31 20:23:17 +00:00
|
|
|
Application
|
|
|
|
</x-forms.button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
@endif
|
2023-06-12 20:02:10 +00:00
|
|
|
<div class="flex gap-2">
|
|
|
|
<x-forms.input id="github_app.name" label="App Name" required />
|
2023-05-16 09:02:51 +00:00
|
|
|
|
2023-06-12 20:02:10 +00:00
|
|
|
@if ($github_app->app_id)
|
|
|
|
<x-forms.input id="github_app.organization" label="Organization" disabled
|
|
|
|
placeholder="Personal user if empty" />
|
|
|
|
@else
|
|
|
|
<x-forms.input id="github_app.organization" label="Organization" placeholder="Personal user if empty" />
|
|
|
|
@endif
|
|
|
|
</div>
|
|
|
|
<div class="flex gap-2">
|
|
|
|
<x-forms.input id="github_app.html_url" label="HTML Url" disabled />
|
|
|
|
<x-forms.input id="github_app.api_url" label="API Url" disabled />
|
|
|
|
</div>
|
|
|
|
<div class="flex gap-2">
|
|
|
|
@if ($github_app->html_url === 'https://github.com')
|
|
|
|
<x-forms.input id="github_app.custom_user" label="User" disabled />
|
|
|
|
<x-forms.input type="number" id="github_app.custom_port" label="Port" disabled />
|
|
|
|
@else
|
|
|
|
<x-forms.input id="github_app.custom_user" label="User" required />
|
|
|
|
<x-forms.input type="number" id="github_app.custom_port" label="Port" required />
|
|
|
|
@endif
|
|
|
|
</div>
|
2023-05-08 11:36:49 +00:00
|
|
|
@if ($github_app->app_id)
|
2023-06-12 20:02:10 +00:00
|
|
|
<div class="flex gap-2">
|
|
|
|
<x-forms.input type="number" id="github_app.app_id" label="App Id" disabled />
|
|
|
|
<x-forms.input type="number" id="github_app.installation_id" label="Installation Id" disabled />
|
|
|
|
</div>
|
|
|
|
<div class="flex gap-2">
|
|
|
|
<x-forms.input id="github_app.client_id" label="Client Id" type="password" disabled />
|
|
|
|
<x-forms.input id="github_app.client_secret" label="Client Secret" type="password" disabled />
|
|
|
|
<x-forms.input id="github_app.webhook_secret" label="Webhook Secret" type="password" disabled />
|
2023-05-08 11:36:49 +00:00
|
|
|
</div>
|
2023-06-12 20:02:10 +00:00
|
|
|
<x-forms.checkbox noDirty label="System Wide?"
|
|
|
|
helper="If checked, this GitHub App will be available for everyone in this Coolify instance."
|
|
|
|
instantSave id="is_system_wide" />
|
|
|
|
@else
|
|
|
|
<x-forms.checkbox
|
|
|
|
helper="If checked, this GitHub App will be available for everyone in this Coolify instance." noDirty
|
|
|
|
label="System Wide?" instantSave id="is_system_wide" />
|
2023-05-08 11:36:49 +00:00
|
|
|
@endif
|
|
|
|
</form>
|
2023-05-18 11:26:35 +00:00
|
|
|
@if (!$github_app->app_id)
|
|
|
|
<script>
|
|
|
|
function createGithubApp() {
|
|
|
|
const {
|
|
|
|
organization,
|
|
|
|
uuid,
|
|
|
|
html_url
|
|
|
|
} = @json($github_app);
|
|
|
|
let baseUrl = @js($host);
|
|
|
|
const name = @js($name);
|
|
|
|
const isDev = @js(config('app.env')) === 'local';
|
|
|
|
const devWebhook = @js(config('coolify.dev_webhook'));
|
|
|
|
if (isDev && devWebhook) {
|
|
|
|
baseUrl = devWebhook;
|
|
|
|
}
|
|
|
|
const webhookBaseUrl = `${baseUrl}/webhooks`;
|
|
|
|
const path = organization ? `organizations/${organization}/settings/apps/new` : 'settings/apps/new';
|
|
|
|
const data = {
|
|
|
|
name,
|
|
|
|
url: baseUrl,
|
|
|
|
hook_attributes: {
|
|
|
|
url: `${webhookBaseUrl}/source/github/events`,
|
|
|
|
active: true,
|
|
|
|
},
|
|
|
|
redirect_url: `${webhookBaseUrl}/source/github/redirect`,
|
|
|
|
callback_urls: [`${baseUrl}/login/github/app`],
|
|
|
|
public: false,
|
|
|
|
request_oauth_on_install: false,
|
|
|
|
setup_url: `${webhookBaseUrl}/source/github/install?source=${uuid}`,
|
|
|
|
setup_on_update: true,
|
|
|
|
default_permissions: {
|
|
|
|
contents: 'read',
|
|
|
|
metadata: 'read',
|
|
|
|
pull_requests: 'read',
|
|
|
|
emails: 'read'
|
|
|
|
},
|
|
|
|
default_events: ['pull_request', 'push']
|
|
|
|
};
|
|
|
|
const form = document.createElement('form');
|
|
|
|
form.setAttribute('method', 'post');
|
|
|
|
form.setAttribute('action', `${html_url}/${path}?state=${uuid}`);
|
|
|
|
const input = document.createElement('input');
|
|
|
|
input.setAttribute('id', 'manifest');
|
|
|
|
input.setAttribute('name', 'manifest');
|
|
|
|
input.setAttribute('type', 'hidden');
|
|
|
|
input.setAttribute('value', JSON.stringify(data));
|
|
|
|
form.appendChild(input);
|
|
|
|
document.getElementsByTagName('body')[0].appendChild(form);
|
|
|
|
form.submit();
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
@endif
|
2023-05-08 11:36:49 +00:00
|
|
|
</div>
|