Git Product home page Git Product logo

gh-gei's Introduction

GitHub Enterprise Importer CLI

Actions Status: CI

The GitHub Enterprise Importer (GEI, formerly Octoshift) is a highly customizable API-first migration offering designed to help you move your enterprise to GitHub Enterprise Cloud. The GEI-CLI wraps the GEI APIs as a cross-platform console application to simplify customizing your migration experience.

GEI is generally available for repository migrations originating from Azure DevOps or GitHub that target GitHub Enterprise Cloud. It is in public beta for repository migrations from BitBucket Server and Data Center to GitHub Enterprise Cloud.

Using the GEI CLI

There are 3 separate CLIs that we ship as extensions for the official GitHub CLI:

  • gh gei - Run migrations between GitHub products
  • gh ado2gh - Run migrations from Azure DevOps to GitHub
  • gh bbs2gh - Run migrations from BitBucket Server or Data Center to GitHub

To use gh gei first install the latest GitHub CLI, then run the command

gh extension install github/gh-gei

To use gh ado2gh first install the latest GitHub CLI, then run the command

gh extension install github/gh-ado2gh

To use gh bbs2gh first install the latest GitHub CLI, then run the command

gh extension install github/gh-bbs2gh

We update the extensions frequently, so make sure you update them on a regular basis:

gh extension upgrade github/gh-gei

To see the available commands and options run:

gh gei --help

gh ado2gh --help

gh bbs2gh --help

GitHub to GitHub Usage (GitHub.com -> GitHub.com)

  1. Create Personal Access Tokens with access to the source GitHub org, and the target GitHub org (for more details on scopes needed refer to our official documentation).

  2. Set the GH_SOURCE_PAT and GH_PAT environment variables.

  3. Run the generate-script command to generate a migration PowerShell script.

gh gei generate-script --github-source-org ORGNAME --github-target-org ORGNAME

  1. The previous command will have created a migrate.ps1 script. Review the steps in the generated script and tweak if necessary.

  2. The migrate.ps1 script requires PowerShell to run. If not already installed see the install instructions to install PowerShell on Windows, Linux, or Mac. Then run the script.

Refer to the official documentation for more details, including differences when migrating from GitHub Enterprise Server.

Azure DevOps to GitHub Usage

  1. Create Personal Access Tokens with access to the Azure DevOps org, and the GitHub org (for more details on scopes needed refer to our official documentation).

  2. Set the ADO_PAT and GH_PAT environment variables.

  3. Run the generate-script command to generate a migration script.

gh ado2gh generate-script --ado-org ORGNAME --github-org ORGNAME --all

  1. The previous command will have created a migrate.ps1 PowerShell script. Review the steps in the generated script and tweak if necessary.

  2. The migrate.ps1 script requires PowerShell to run. If not already installed see the install instructions to install PowerShell on Windows, Linux, or Mac. Then run the script.

Refer to the official documentation for more details.

Bitbucket Server and Data Center to GitHub Usage

  1. Create Personal Access Token for the target GitHub org (for more details on scopes needed refer to our official documentation).

  2. Set the GH_PAT, BBS_USERNAME, and BBS_PASSWORD environment variables.

  3. If your Bitbucket Server or Data Center instance runs on Windows, set the SMB_PASSWORD environment variable.

  4. Run the generate-script command to generate a migration script.

> gh bbs2gh generate-script --bbs-server-url BBS-SERVER-URL \
  --github-org DESTINATION \
  --output FILENAME \
  # Use the following options if your Bitbucket Server instance runs on Linux
  --ssh-user SSH-USER --ssh-private-key PATH-TO-KEY
  # Use the following options if your Bitbucket Server instance runs on Windows
  --smb-user SMB-USER
  # Use the following option if you are running a Bitbucket Data Center cluster or your Bitbucket Server is behind a load balancer
  --archive-download-host ARCHIVE-DOWNLOAD-HOST
  1. The previous command will have created a migrate.ps1 PowerShell script. Review the steps in the generated script and tweak if necessary.

  2. The migrate.ps1 script requires PowerShell to run. If not already installed see the install instructions to install PowerShell on Windows, Linux, or Mac. Then run the script.

Refer to the official documentation for more details.

Skipping version checks

When the CLI is launched, it logs if a newer version of the CLI is available. You can skip this check by setting the GEI_SKIP_VERSION_CHECK environment variable to true.

Skipping GitHub status checks

When the CLI is launched, it logs a warning if there are any ongoing GitHub incidents that might affect your use of the CLI. You can skip this check by setting the GEI_SKIP_STATUS_CHECK environment variable to true.

Contributions

See Contributing for more info on how to get involved.

gh-gei's People

Contributors

andrekolodochka avatar aringhazarian avatar begonaguereca avatar brianaj avatar dependabot[bot] avatar dmckinstry avatar dpmex4527 avatar dylan-smith avatar gohana avatar hfishback01 avatar jessicaliu100 avatar jeviet avatar juanmrad avatar madkoo avatar martins-vds avatar mulana avatar nelsonprsousa avatar oakeyc avatar petermeglis avatar pnsk avatar robandpdx avatar roferg avatar slenguyen avatar synthead avatar tambling avatar teja-nanduri avatar tiago-soczek avatar timrogers avatar tspascoal avatar xiaonile avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gh-gei's Issues

Self-Service Migrations

Bring the Octoshift CLI to a state that aligns with how customers want to use Octoshift, covers running migrations from ADO, GHES & GHEC, and can be picked up self-service and used without in hand holding for the first few migrations. This will help to reduce the time investment that's needed to get a customer started using Octoshift. While also bringing the CLI benefit to GHES and GHEC migration customers.

DRI: @dylan-smith

Batches

Basic Usage Docs

Create some basic docs on how to use the CLI tooling. Especially what PAT scopes are needed in order to run the various commands.

I've been testing with All Orgs + Full Access for the ADO PAT, and similarly broad scopes for the GH PAT.

The scopes needed will be diff for diff commands (e.g. generate-script only does ADO reads, but obviously some other commands are writing stuff).

There's another issue #20 to code in some explicit tests for the right permissions, this issue represents just figuring out what's needed and documenting it.

Support Parallel Migrations

The current tooling only supports running one repo migration at a time and waiting for completion before moving onto the next. The backend API's support queueing up many jobs at once, and the CLI tooling needs to be updated to support it.

This will likely be handled by changing the logic contained in the migration script generated from the generate-script command. We may want to support adding an option to generate-script giving the user control over whether the migrations run in parallel or not (the default should be parallel). Will need an option on migrate-repo also indicating whether it should wait or not (default is to queue and return - i.e. not wait).

Tasks

Accept PAT's as cli args in addition to env vars

I did this as env vars to start because it's usually a more convenient way to pass around secrets, especially if you may be screen sharing while using the CLI. And you definately don't want secrets to be included in the generated script from the generate-script command.

For convenience though, an option to specify them directly as CLI args would be a nice addition.

Poor Mans Dependency Injection

Should put in place some poor man's DI (for the AdoApi/GitHubApi/AdoClient/GithubClient) so that the Command classes are easier to test and mock out the Api layers.

Full blow DI framework is probably overkill at this point.

Generate Rollback Script

add an extra option to generate-script that can generate a 2nd rollback script that undoes what the migration script does.

This will make doing dry-runs easier, especially when a customer wants to do a dry-run that involves modifying things in ADO (e.g. pipelines)

Create automated e2e test(s)

My thoughts on best way to do this:

Have a pre-existing ADO org + GH org
GH org should be using EMU's
Have the relevant AAD groups created and sync'd to GH already

Write some setup/teardown code that does the following:

  • deletes all team projects in ADO org (except the 1 that has the service connection for pipelines)
  • deletes all repos in GH org
  • deletes all teams in GH org

Then have some sample data generation code:

  • Create a handful of team projects
  • Create a handful of repos (with a couple of PR's optionally)
  • Create a handful of pipelines
  • Create a couple of work items

Run the test(s):

  • generate-script
  • run the script
  • trigger a couple pipelines (optional)
  • create a commit/PR referencing a work item (optional)

Assert on results:

  • script ran without errors (probably need to capture stderr and exit codes)
  • repos created in GH
  • PR's created in GH
  • Pipelines pointing to GH repos
  • Boards integrations configured
  • teams created in GH (and linked to IdP groups)
  • autolink references configured
  • etc

Smart defaults for duplicate repo names

If duplicate repo names are detected, instead of just spitting out a warning and putting the onus on the user, maybe do something intelligent to ensure unique repo names, then the user can always changed the migration script if desired.

E.g. prefix with Team Project and/or Org name (if not already doing that), and/or toss a number on the end

Split integrate-boards into one call per GH repo

Right now it accepts a comma-separated list of github repos, would be better if you simply called the command once per repo.

This will require a change in implementation, because right now it creates the connection and adds the repos all in one call. But the api's needed are slightly different to add a repo to an existing connection.

This is important because if a customer wanted to migrate only some repos in a team project, then later migrate the rest. The integrate boards command as it stands today won't work right. But this change will fix that.

Make it work without requiring the All Orgs scope on the ADO PAT

Without the all orgs scope the API call to get the list of orgs won't work, and I believe the API call to get the Org ID will also fail. We can get around the first problem by making the user pass an org name as a CLI argument. Not sure how to get around the 2nd issue. There must be some API end point we can use to get the Org ID for the org that the PAT is scoped to (I just don't know what it is)

More options to configure generate-script behavior

Default behavior should be to generate the minimum possible scripts - probably just the migrate-repo commands.

Then have optional arguments that can be passed to generate-script to add more functions to the generated script. E.g.:
--create-teams
--link-Idp-groups
--rewire-pipelines
--boards-integration
--lock-ado-repo
etc

This should involve the removal of the existing --repos-only flag

Possibly include a --all or something similar flag for customers that want to do all the things.

Edit

Based on the below conversation we need to following options:

  • --create-teams
  • --link-idp-groups (also implies --create-teams)
  • --lock-ado-repos
  • --disable-ado-repos
  • --add-teams-to-repos
  • --integrate-boards
  • --rewire-pipelines
  • --all

IdP Group Linking doesn't work with EMU

The current API endpoints are not the right ones for EMU. We must not have fully tested that capability with DFIN because they didn't have the permissions to create AAD groups for us to test with.

We probably need to detect whether it's EMU or team-sync and call the right endpoints. But if only one of those scenarios is working it should be EMU first.

Add lock-ado-repo command

The current command disable-ado-repo makes it unreadable.

We should have a lock-ado-repo command that makes it read-only pre-migration, then use disable-ado-repo post-migration.

We already implemented this for DFIN, need to port it to this codebase.

Demo video

Create a video and link it in the readme for how to use this tool

Repo access for Octoshift externs

Octoshift has two externs this fall, and they are working on a cli that is intended to be used as a planning tool for customers. That repo is located here. Eventually, we hope to release our tool into open source, hosted on npm.

There is some overlap in functionality between the two utilities, and I think it would be very helpful for our externs to see the structure of the OctoshiftCLI and how API interactions are being made.

The ask: I'd like to request read-only access to this repo for arypat and kevinmsmith131 until mid-December.

Crash while trying to generate scripts with --repos-only for Assurant

NOTE: This FastTrack engagement ends tomorrow; they are friendly and may be willing to help troubleshoot beyond tomorrow, but right now we have a window.

  1. The existing PAT worked fine with individual repo migration but not with generate-script
  2. The failure seems to be as we're enumerating pipelines (which shouldn't me necessary with the --repos-only flag)
  3. The customer asserts that the PAT is an ADO Org Admin
  4. Looking at the pipelines, we couldn't see any security overrides - it looks like they should have permissions

image

cc: @mickeygousset @dylan-smith

Add CONTRIBUTING.md

Include brief overview of how the code is structured.

e.g. Program.cs -> Commands -> Api -> Client

And testing + static analysis rules we follow.

etc etc

Set repo visibility

Customers have asked if it's possible to add an option to let them set a state other than private for a repo when it's done migrating. This capability is already implemented in Octoshift, so this issue tracks passing the appropriate data to Octoshift via the CLI to use this feature.

The customer can configure this in the CLI. When they run generate script we will add a --target-repo-visibility option to migrate repo that by default matches the state that the source repo was in.

Todo

  • Update the CLI generate script to add a --target-repo-visibility to the migrate-repo command that adds the state that the source repo was in (i.e. private/public/internal). If the field isn't included then the default should be private.
  • --target-repo-visibility should be included in for ado2gh customers. We can just default to private for that scenario.

Need to update the generated `./octoshift` to `octoshift` in generate-script command

When the following command runs:

octoshift generate-script --github-org <Your GitHub Organization> --ado-org <Your ADO organization> --output migrate.sh

This will generate a file called migrate.sh which starts with ./octoshift. However, this should be just octoshift. Otherwise, it will just look at the current path for octoshift CLI tool.

Publish Test Results

Probably as a PR comment using one of the custom actions out there that automate this.

Get `Owner xxx is not authorized to perform imports` error from `createMgirationSource` when migration runs

I am getting an error when migrate.sh runs after executing the following command:

octoshift generate-script --github-org <Your GitHub Organization> --ado-org <Your ADO organization> --output migrate.sh
[hh:mm AM] [DEBUG] RESPONSE (OK): {"data":{"createMigrationSource":null},"errors":[{"type":"FORBIDDEN","path":["createMigrationSource"],"locations":[{"line":1,"column":132}],"message":"Owner xxx is not authorized to perform imports."}]}

I am guessing this is because I ignored to setup Azure Pipeline App in my GitHub and connected with Azure DevOps.

[hh:mm PM] [INFO]     Repo: xxx
[hh:mm PM] [WARNING] CANNOT FIND GITHUB APP SERVICE CONNECTION IN ADO ORGANIZATION: xxxx. You must install the Pipelines app in GitHub and connect it to any Team Project in this ADO Org first.

Explicit validation of PAT permissions

Right now if a PAT doesn't have the right permissions, some of the API calls will just crash and spit out a stack trace.

Would probably be a nicer experience if the tooling started by explicitly validating the PAT(s) had the necessary permissions, and giving user-friendly error messages if they didn't.

Bake version into binaries to match release version

When building the artifacts to publish a new release, we're not baking the version number (from the release/tag) into the binary. So when you do octoshift --version it will always show 1.0.0.

In old .net this would be done by updating the assemblyinfo.cs files, can't remember how it's done in .Net core.

Command to create AAD groups

If the approach is to create a Maintainers/Admins GH team for each team project, then map those to AAD groups. The way it works now is the customer has to create the AAD groups in advance, then the CLI will do the GH Team linking. Would probably be better if the CLI had the capability to also create the AAD groups as part of the migration process.

This will require credentials to be able to write to AAD (i.e. service principal client id/secret).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.