check if repo is empty, create readme if it is (#45)

This commit is contained in:
Kosta Petan
2024-04-05 16:34:15 +02:00
committed by GitHub
parent cc66a1ca71
commit 2bece0d27e

View File

@@ -80,6 +80,17 @@ public class GithubService : IManageGithub
try
{
var ghRepo = await _ghClient.Repository.Get(org, repo);
if (ghRepo.Size == 0)
{
// Create a new file and commit it to the repository
var createChangeSet = await _ghClient.Repository.Content.CreateFile(
org,
repo,
"README.md",
new CreateFileRequest("Initial commit", "# Readme")
);
}
await _ghClient.Git.Reference.CreateBranch(org, repo, branch, ghRepo.DefaultBranch);
}
catch (Exception ex)