feat: public repo deployment
This commit is contained in:
@@ -25,8 +25,10 @@
|
||||
const gitUrl = publicRepositoryLink.replace('http://', '').replace('https://', '');
|
||||
let [host, ...path] = gitUrl.split('/');
|
||||
const [owner, repository, ...branch] = path;
|
||||
|
||||
ownerName = owner;
|
||||
repositoryName = repository;
|
||||
|
||||
if (branch[0] === 'tree') {
|
||||
branchName = branch[1];
|
||||
await saveRepository();
|
||||
@@ -42,20 +44,20 @@
|
||||
}
|
||||
const apiUrl = `${protocol}://${host}`;
|
||||
|
||||
const repositoryDetails = await get(`${apiUrl}/repos/${owner}/${repository}`);
|
||||
const repositoryDetails = await get(`${apiUrl}/repos/${ownerName}/${repositoryName}`);
|
||||
projectId = repositoryDetails.id.toString();
|
||||
|
||||
let branches: any[] = [];
|
||||
let page = 1;
|
||||
let branchCount = 0;
|
||||
loading.branches = true;
|
||||
const loadedBranches = await loadBranchesByPage(apiUrl, owner, repository, page);
|
||||
const loadedBranches = await loadBranchesByPage(apiUrl, ownerName, repositoryName, page);
|
||||
branches = branches.concat(loadedBranches);
|
||||
branchCount = branches.length;
|
||||
if (branchCount === 100) {
|
||||
while (branchCount === 100) {
|
||||
page = page + 1;
|
||||
const nextBranches = await loadBranchesByPage(apiUrl, owner, repository, page);
|
||||
const nextBranches = await loadBranchesByPage(apiUrl, ownerName, repositoryName, page);
|
||||
branches = branches.concat(nextBranches);
|
||||
branchCount = nextBranches.length;
|
||||
}
|
||||
@@ -68,7 +70,6 @@
|
||||
}
|
||||
async function loadBranchesByPage(apiUrl: string, owner: string, repository: string, page = 1) {
|
||||
return await get(`${apiUrl}/repos/${owner}/${repository}/branches?per_page=100&page=${page}`);
|
||||
// console.log(publicRepositoryLink);
|
||||
}
|
||||
async function saveRepository(event?: any) {
|
||||
try {
|
||||
@@ -81,7 +82,7 @@
|
||||
type
|
||||
});
|
||||
await post(`/applications/${id}/configuration/repository`, {
|
||||
repository: `${repositoryName}/${branchName}`,
|
||||
repository: `${ownerName}/${repositoryName}`,
|
||||
branch: branchName,
|
||||
projectId,
|
||||
autodeploy: false,
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
export let type: any;
|
||||
export let application: any;
|
||||
export let isPublicRepository: boolean;
|
||||
console.log(isPublicRepository)
|
||||
|
||||
function checkPackageJSONContents({ key, json }: { key: any; json: any }) {
|
||||
return json?.dependencies?.hasOwnProperty(key) || json?.devDependencies?.hasOwnProperty(key);
|
||||
}
|
||||
@@ -237,7 +237,7 @@
|
||||
if (error.message === 'Bad credentials') {
|
||||
const { token } = await get(`/applications/${id}/configuration/githubToken`);
|
||||
$appSession.tokens.github = token;
|
||||
return await scanRepository()
|
||||
return await scanRepository();
|
||||
}
|
||||
return errorNotification(error);
|
||||
} finally {
|
||||
@@ -246,7 +246,12 @@
|
||||
}
|
||||
}
|
||||
onMount(async () => {
|
||||
await scanRepository();
|
||||
if (!isPublicRepository) {
|
||||
await scanRepository();
|
||||
} else {
|
||||
foundConfig = findBuildPack('node', packageManager);
|
||||
scanning = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -263,27 +268,25 @@
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
|
||||
|
||||
<div class="max-w-7xl mx-auto ">
|
||||
<div class="title pb-2">Coolify Buildpacks</div>
|
||||
<div class="flex flex-wrap justify-center">
|
||||
{#each buildPacks.filter(bp => bp.isCoolifyBuildPack === true) as buildPack}
|
||||
<div class="p-2">
|
||||
<BuildPack {packageManager} {buildPack} {scanning} bind:foundConfig />
|
||||
</div>
|
||||
{/each}
|
||||
{#each buildPacks.filter((bp) => bp.isCoolifyBuildPack === true) as buildPack}
|
||||
<div class="p-2">
|
||||
<BuildPack {packageManager} {buildPack} {scanning} bind:foundConfig />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="max-w-7xl mx-auto ">
|
||||
<div class="title pb-2">Heroku</div>
|
||||
<div class="flex flex-wrap justify-center">
|
||||
{#each buildPacks.filter(bp => bp.isHerokuBuildPack === true) as buildPack}
|
||||
<div class="p-2">
|
||||
<BuildPack {packageManager} {buildPack} {scanning} bind:foundConfig />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{#each buildPacks.filter((bp) => bp.isHerokuBuildPack === true) as buildPack}
|
||||
<div class="p-2">
|
||||
<BuildPack {packageManager} {buildPack} {scanning} bind:foundConfig />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -133,6 +133,7 @@
|
||||
autodeploy = !autodeploy;
|
||||
}
|
||||
if (name === 'isBot') {
|
||||
if ($status.application.isRunning) return;
|
||||
isBot = !isBot;
|
||||
application.settings.isBot = isBot;
|
||||
setLocation(application, settings);
|
||||
@@ -345,8 +346,11 @@
|
||||
<label for="gitSource" class="text-base font-bold text-stone-100"
|
||||
>{$t('application.git_source')}</label
|
||||
>
|
||||
{#if isDisabled}
|
||||
<input disabled={isDisabled} value={application.gitSource.name} />
|
||||
{#if isDisabled || application.settings.isPublicRepository}
|
||||
<input
|
||||
disabled={isDisabled || application.settings.isPublicRepository}
|
||||
value={application.gitSource.name}
|
||||
/>
|
||||
{:else}
|
||||
<a
|
||||
href={`/applications/${id}/configuration/source?from=/applications/${id}`}
|
||||
@@ -363,8 +367,11 @@
|
||||
<label for="repository" class="text-base font-bold text-stone-100"
|
||||
>{$t('application.git_repository')}</label
|
||||
>
|
||||
{#if isDisabled}
|
||||
<input disabled={isDisabled} value="{application.repository}/{application.branch}" />
|
||||
{#if isDisabled || application.settings.isPublicRepository}
|
||||
<input
|
||||
disabled={isDisabled || application.settings.isPublicRepository}
|
||||
value="{application.repository}/{application.branch}"
|
||||
/>
|
||||
{:else}
|
||||
<a
|
||||
href={`/applications/${id}/configuration/repository?from=/applications/${id}&to=/applications/${id}/configuration/buildpack`}
|
||||
@@ -488,6 +495,7 @@
|
||||
on:click={() => changeSettings('isBot')}
|
||||
title="Is your application a bot?"
|
||||
description="You can deploy applications without domains. <br>They will listen on <span class='text-green-500 font-bold'>IP:EXPOSEDPORT</span> instead.<br></Setting><br>Useful to host <span class='text-green-500 font-bold'>Twitch bots.</span>"
|
||||
disabled={$status.application.isRunning}
|
||||
/>
|
||||
</div>
|
||||
{#if !isBot}
|
||||
@@ -770,15 +778,17 @@
|
||||
<div class="title">{$t('application.features')}</div>
|
||||
</div>
|
||||
<div class="px-10 pb-10">
|
||||
<div class="grid grid-cols-2 items-center">
|
||||
<Setting
|
||||
isCenter={false}
|
||||
bind:setting={autodeploy}
|
||||
on:click={() => changeSettings('autodeploy')}
|
||||
title={$t('application.enable_automatic_deployment')}
|
||||
description={$t('application.enable_auto_deploy_webhooks')}
|
||||
/>
|
||||
</div>
|
||||
{#if !application.settings.isPublicRepository}
|
||||
<div class="grid grid-cols-2 items-center">
|
||||
<Setting
|
||||
isCenter={false}
|
||||
bind:setting={autodeploy}
|
||||
on:click={() => changeSettings('autodeploy')}
|
||||
title={$t('application.enable_automatic_deployment')}
|
||||
description={$t('application.enable_auto_deploy_webhooks')}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
{#if !application.settings.isBot}
|
||||
<div class="grid grid-cols-2 items-center">
|
||||
<Setting
|
||||
|
||||
@@ -87,9 +87,7 @@
|
||||
</div>
|
||||
|
||||
<div class="mx-auto max-w-6xl rounded-xl px-6 pt-4">
|
||||
<div class="flex justify-center py-4 text-center">
|
||||
<Explainer customClass="w-full" text={$t('application.storage.persistent_storage_explainer')} />
|
||||
</div>
|
||||
|
||||
<table class="mx-auto border-separate text-left">
|
||||
<thead>
|
||||
<tr class="h-12">
|
||||
@@ -109,4 +107,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="flex justify-center py-4 text-center">
|
||||
<Explainer customClass="w-full" text={$t('application.storage.persistent_storage_explainer')} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user