Skip to content

GitHub CLI extension to generate GitHub repository migrations

Notifications You must be signed in to change notification settings

andyfeller/gh-repo-export

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gh-repo-export

A gh extension to generate GitHub organization repository migrations.

Quickstart

  1. Download and install jq
  2. gh extension install andyfeller/gh-repo-export
  3. gh repo-export <organization> <repo> ...
  4. Profit! 💰 💸 🤑 💸 💰

Usage

Note gh-repo-export requires the use of coarse-grained v1 PAT token with repo and admin:org scopes.

$ gh repo-export --help

Bulk exports a list of Git repositories from an organization

USAGE
  gh repo-export [flags] <organization> <repo1> <repo2> ... <repoN>
  gh repo-export [flags] <organization> <path/to/repos file>

FLAGS
      --archive=string                Name of archive excluding extension; default 'migration-archive-<migration_id>'
      --archive-per-repo              Generates 1 archive per repository instead of 1 archive for all repositories
  -d, --debug                         Enable debugging
      --exclude-attachments           Indicates attachments should be excluded from the migration
      --exclude-git-data              Indicates git data should be excluded from the migration
      --exclude-metadata              Indicates metadata should be excluded from the migration
      --exclude-owner-projects        Indicates projects owned by the organization or users should be excluded from the migration
      --exclude-releases              Indicates releases should be excluded from the migration
  -h, --help                          Display help usage
      --hostname=string               Hostname of the GitHub instance to authenticate with
      --lock-repositories             Indicates repositories should be locked (to prevent manipulation) while migrating data
      --skip-download                 Skip downloading the archive(s), instead outputting the URL(s) to stdout (curl and sed required)

EXAMPLES
  # Generate 1 archive containing test1 repository, reading repositories from arguments
  $ gh repo-export tinyfists test1

  # Generate 1 archive containing both test1 and test2 repositories, reading repositories from arguments
  $ gh repo-export tinyfists test1 test2

  # Generate 1 archive containing both test1 and test2 repositories, reading repositories from arguments, and output the archive URL instead of downloading
  $ gh repo-export --skip-download tinyfists test1 test2

  # Generate 2 archives, 1 containing test1 repository and 1 containing test2 repository, reading repositories from arguments
  $ gh repo-export --archive-per-repo tinyfists test1 test2

  # Generate 2 archives, 1 containing test1 repository and 1 containing test2 repository, reading repositories from 'repos.txt' file
  $ gh repo-export --archive-per-repo tinyfists repos.txt

Examples

$ gh repo-export tinyfists issue-driven-github-admin

Reading repositories from arguments: issue-driven-github-admin
Starting migration 3431913 for repositories: issue-driven-github-admin
Watching migration 3431913 with 'exporting' state
Watching migration 3431913 with 'exporting' state
Watching migration 3431913 with 'exporting' state
Watching migration 3431913 with 'exported' state
Downloading migration 3431913 archive to migration-archive-3431913.tar.gz

$ gh repo-export tinyfists issue-driven-github-admin actions-experiments

Reading repositories from arguments: issue-driven-github-admin actions-experiments
Starting migration 3431922 for repositories: issue-driven-github-admin actions-experiments
Watching migration 3431922 with 'exporting' state
Watching migration 3431922 with 'exporting' state
Watching migration 3431922 with 'exporting' state
Watching migration 3431922 with 'exporting' state
Watching migration 3431922 with 'exported' state
Downloading migration 3431922 archive to migration-archive-3431922.tar.gz

$ gh repo-export --skip-download tinyfists issue-driven-github-admin actions-experiments

Reading repositories from arguments: issue-driven-github-admin actions-experiments
Starting migration 3431922 for repositories: issue-driven-github-admin actions-experiments
Watching migration 3431922 with 'exporting' state
Watching migration 3431922 with 'exporting' state
Watching migration 3431922 with 'exporting' state
Watching migration 3431922 with 'exporting' state
Watching migration 3431922 with 'exported' state
Archive URL for migration 3762306: https://github-cloud.s3.amazonaws.com/migration/...

$ gh repo-export --archive-per-repo tinyfists issue-driven-github-admin actions-experiments

Reading repositories from arguments: issue-driven-github-admin actions-experiments
Starting migration 3431937 for repositories: issue-driven-github-admin
Starting migration 3431938 for repositories: actions-experiments
Watching migration 3431937 with 'exporting' state
Watching migration 3431938 with 'exporting' state
Watching migration 3431937 with 'exporting' state
Watching migration 3431938 with 'exported' state
Watching migration 3431937 with 'exporting' state
Watching migration 3431937 with 'exported' state
Downloading migration 3431937 archive to migration-archive-3431937.tar.gz
Downloading migration 3431938 archive to migration-archive-3431938.tar.gz

$ gh repo-export tinyfists repos.txt

Reading repositories from file: repos.txt
Starting migration 3431982 for repositories:  issue-driven-github-admin actions-experiments
Watching migration 3431982 with 'exporting' state
Watching migration 3431982 with 'exporting' state
Watching migration 3431982 with 'exporting' state
Watching migration 3431982 with 'exported' state
Downloading migration 3431982 archive to migration-archive-3431982.tar.gz

Setup

Like any other gh CLI extension, gh-repo-export is trivial to install or upgrade and works on most operating systems:

About

GitHub CLI extension to generate GitHub repository migrations

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages