Skip to content

soenneker/soenneker.github.filestore

Soenneker.GitHub.FileStore

A high-level file system utility for GitHub repositories, built on the GitHub OpenAPI client. Supports reading, writing, deleting, listing, and checking file existence via the GitHub Contents API.

Features

  • ?? Read file content from a GitHub repository
  • ?? Write new files with commit messages and optional branch targeting
  • ? Delete files with SHA validation
  • ?? List directory contents
  • ? Check for file existence
  • ?? Built on top of a typed OpenAPI GitHub client

Installation

dotnet add package Soenneker.GitHub.FileStore

Setup

builder.Services.AddGitHubFileStoreAsSingleton();

This will register all necessary dependencies, including the underlying GitHub OpenAPI client.

?? Note: The GitHub access token must be provided via configuration under the key: GitHub:Token.

Example Usage

public class MyService
{
    private readonly IGitHubFileStore _store;

    public MyService(IGitHubFileStore store)
    {
        _store = store;
    }

    public async Task Run()
    {
        string content = await _store.Read("owner", "repo", "README.md");

        await _store.Create("owner", "repo", "newfile.txt", "Hello world!");

        bool exists = await _store.Exists("owner", "repo", "README.md");

        var files = await _store.List("owner", "repo", "docs");

        await _store.Delete("owner", "repo", "oldfile.txt");
    }
}

Related Packages

About

A high-level file system utility for GitHub repositories, built on the GitHub OpenAPI client. Supports reading, writing, deleting, listing, and checking file existence via the GitHub Contents API.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

 
 
 

Contributors

Languages