feat: public repo deployment

This commit is contained in:
Andras Bacsai
2022-08-18 15:29:59 +02:00
parent 0c24134ac2
commit 4e7e9b2cfc
12 changed files with 159 additions and 128 deletions

View File

@@ -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,

View File

@@ -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}