Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/observability-repo-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,22 @@ export class ObservabilityRepoManager {
if (error instanceof GitbeakerRequestError && error.cause?.response.status === 404) {
console.log('Le fichier n\'existe pas')
// Si le fichier n'existe pas, création
await this.gitlabApi.RepositoryFiles.create(project.id, filePath, branch, encodedContent, commitMessage)
try {
await this.gitlabApi.RepositoryFiles.create(project.id, filePath, branch, encodedContent, commitMessage)
} catch (createError) {
if (createError instanceof GitbeakerRequestError && createError.cause?.response.status === 400) {
// Create a commit for the new file
await this.gitlabApi.Commits.create(project.id, branch, commitMessage, [
{
action: 'create',
filePath,
content: encodedContent,
},
])
} else {
throw createError
}
}
console.log(`Fichier YAML créé et poussé: ${filePath}`)
return
}
Expand Down