Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save robandpdx/32109989fafd4f0d1a9db11322fa1377 to your computer and use it in GitHub Desktop.
Save robandpdx/32109989fafd4f0d1a9db11322fa1377 to your computer and use it in GitHub Desktop.
Instructions for migrating a repo from GitHub Enterprise Server to GitHub Enterprise Cloud using `gh gei` with an unsupported blob storage provider or a supported blob storage provider using an unsupported authentication mechanism

These instructions explain how to migrate a repo from GitHub Enterprise Server to GitHub Enterprise Cloud using the gh gei CLI when either:

  • (a) you want to use an unsupported blob storage provider; or
  • (b) you want to use a supported blob storage provider with different authentication

The following instructions assume that you have curl and jq installed. There are available for Linux, macOS and Windows Subsystem for Linux (WSL).

  1. Make a note of your GitHub Enterprise Server hostname (e.g. github.acmecorp.com) and expose it as the GHES_HOST environment variable: export GHES_HOST=github.acmecorp.com.
  2. Make a note of the GitHub Enterprise Server organization that owns your origin repo, and expose it as the GHES_ORGANIZATION environment variable: export GHES_ORGANIZATION=engineering.
  3. Make a note of the name of the repo you are migrating in GitHub Enterprise Server, and expose it as the GHES_REPO environment variable: export GHES_REPO=webapp.
  4. Create a personal access token (PAT) with the read:org and repo scopes and expose it as the GITHUB_TOKEN environment variable: export GITHUB_TOKEN=xxx.
  5. Start generating your migration archive by running export MIGRATION_ID=$(curl https://$GHES_HOST/api/v3/orgs/$GHES_ORGANIZATION/migrations -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Content-Type: application/json" --data "{ \"repositories\": [\"$GHES_REPO\"] }" | jq ".id").
  6. Repeatedly run curl https://$GHES_HOST/orgs/$GHES_ORGANIZATION/migrations/$MIGRATION_ID/archive -H "Authorization: Bearer $GITHUB_TOKEN" until it returns a URL.
  7. Download the archive from the URL in step 6 by running curl <url> --output $GHES_REPO.tar.gz
  8. Upload your archive to your chosen blob storage provider and generate a short-lived URL (e.g. AWS S3 presigned URL or an Azure Blob Storage SAS URL)
  9. Kick off your migration using the GEI CLI, passing in the blob storage URL URL. Your command will look something like this:
gh gei migrate-repo --github-source-org $GHES_ORGANIZATION --source-repo $GHES_REPO --github-target-org Deep-Space-9 --git-archive-url <URL from step 8> --metadata-archive-url <URL from step 8> --wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment