Skip to content

SimonCropp/GitHubSync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHubSync

Build status NuGet Status NuGet Status

A tool to help synchronizing specific files and folders across repositories

See Milestones for release notes.

.net API

NuGet package

https://nuget.org/packages/GitHubSync/

Usage

// Create a new RepoSync
var repoSync = new RepoSync(
    log: Console.WriteLine);

// Add source repo(s)
repoSync.AddSourceRepository(new(
    // Valid credentials for the source repo and all target repos
    credentials: octokitCredentials,
    owner: "UserOrOrg",
    repository: "TheSingleSourceRepository",
    branch: "master"));

// Add sources(s), only allowed when SyncMode == ExcludeAllByDefault
repoSync.AddBlob("sourceFile.txt");
repoSync.AddBlob("code.cs");

// Remove sources(s), only allowed when SyncMode == IncludeAllByDefault
repoSync.AddBlob("sourceFile.txt");
repoSync.AddBlob("code.cs");

// Add target repo(s)
repoSync.AddTargetRepository(new(
    credentials: octokitCredentials,
    owner: "UserOrOrg",
    repository: "TargetRepo1",
    branch: "master"));

repoSync.AddTargetRepository(new(
    credentials: octokitCredentials,
    owner: "UserOrOrg",
    repository: "TargetRepo2",
    branch: "master"));

// Run the sync
await repoSync.Sync(syncOutput: SyncOutput.MergePullRequest);

snippet source | anchor

dotnet Tool

This tool allows reading the configuration from a file. This allows customization of the templates and repositories without having to recompile any code.

Installation

Ensure dotnet CLI is installed.

Install GitHubSync.Tool

dotnet tool install -g GitHubSync.Tool

Usage

Run against the current directory will use githubsync.yaml in the current directory:

githubsync

Run against a specific config file:

githubsync C:\Code\Project\sync.yaml

Configuration definition

The configuration format is yaml. There should be 1 to n number of templates and 1 to n number of (target) repositories.

templates:
  - name: [template name]
    url: [repository url of the template]
    branch: [branch to use, defaults to `master`]
    
repositories:
  - name: [repository name]
    url: [repository url of the target repository]
    branch: [target branch, defaults to `master`]
    autoMerge: [true / false, true is only used when user is allowed to merge PRs on the target repository]
    templates:
      - [list of template names to use in the order to apply]

Example

templates:
  - name: geertvanhorrik
    url: https://github.com/geertvanhorrik/repositorytemplate
    branch: master
  - name: catel
    url: https://github.com/Catel/RepositoryTemplate.Components
    branch: master
  - name: wildgums-components-public
    url: https://github.com/wildgums/RepositoryTemplate.Components.Public
    branch: master
repositories:
  - name: CsvHelper
    url: https://github.com/JoshClose/CsvHelper
    branch: master
    autoMerge: false
    templates:
      - geertvanhorrik
  - name: Catel
    url: https://github.com/catel/catel
    branch: develop
    autoMerge: true
    templates:
      - geertvanhorrik
      - catel
  - name: Orc.Controls
    url: https://github.com/wildgums/orc.controls
    branch: develop
    autoMerge: true
    templates:
      - geertvanhorrik
      - wildgums-components-public

This example will result in the following:

  • CsvHelper => use geertvanhorrik
  • Catel => use geertvanhorrik + catel (combined, so catel can override files)
  • Orc.Controls => use geertvanhorrik + wildgums-components-public (combined, so wildgums-components-public can override files)

Icon

Sync designed by Edward Boatman from The Noun Project.

About

A tool to help synchronizing specific files and folders across GitHub hosted repositories

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Languages