diff --git a/apps/ui/src/routes/applications/[id]/index.svelte b/apps/ui/src/routes/applications/[id]/index.svelte index 0cd8e145f..77c97a295 100644 --- a/apps/ui/src/routes/applications/[id]/index.svelte +++ b/apps/ui/src/routes/applications/[id]/index.svelte @@ -366,11 +366,12 @@ async function reloadCompose() { if (loading.reloadCompose) return; loading.reloadCompose = true; - const composeLocation = application.dockerComposeFileLocation.startsWith('/') - ? application.dockerComposeFileLocation - : `/${application.dockerComposeFileLocation}`; try { if (application.gitSource.type === 'github') { + const composeLocation = application.dockerComposeFileLocation.startsWith('/') + ? application.dockerComposeFileLocation + : `/${application.dockerComposeFileLocation}`; + const headers = isPublicRepository ? {} : { @@ -397,6 +398,17 @@ if (!$appSession.tokens.gitlab) { await getGitlabToken(); } + + const composeLocation = application.dockerComposeFileLocation.startsWith('/') + ? application.dockerComposeFileLocation.substring(1) // Remove the '/' from the start + : application.dockerComposeFileLocation; + + // If the file is in a subdirectory, lastIndex will be > 0 + // Otherwise it will be -1 and path will be an empty string + const lastIndex = composeLocation.lastIndexOf('/') + 1 + const path = composeLocation.substring(0, lastIndex) + const fileName = composeLocation.substring(lastIndex) + const headers = isPublicRepository ? {} : { @@ -404,13 +416,13 @@ }; const url = isPublicRepository ? `` - : `/v4/projects/${application.projectId}/repository/tree`; + : `/v4/projects/${application.projectId}/repository/tree?path=${path}`; const files = await get(`${apiUrl}${url}`, { ...headers }); const dockerComposeFileYml = files.find( (file: { name: string; type: string }) => - file.name === composeLocation && file.type === 'blob' + file.name === fileName && file.type === 'blob' ); const id = dockerComposeFileYml.id;