Git Product home page Git Product logo

github-migrator's Introduction

github-migrator

# create a buildx builder
docker buildx create --use --name builder --driver docker-container --buildkitd-flags '--allow-insecure-entitlement security.insecure'
# create a ssh agent connection your builder can use
eval $(ssh-agent)
# add the target github enterprise key to ssh/scp payload
ssh-add ~/.ssh/id_rsa

# if you need to kill the builder
docker buildx builder rm

export

Just need to provide the source token (SOURCE_TOKEN) and organization(ORGANIZATION) as env vars.

  • Inputs:
    • If the local out directory contains a file named ORGANIZATION.tar.gz then this is moved inside the container instead of pulling freshly from github cloud.
  • Outputs:
    • Expect the ORGANIZATION to have been exported to ORGANIZATION.tar.gz within the container.
SOURCE_TOKEN=ghp_tokenabc123 \
ORGANIZATION=trailmix \
  docker buildx bake export

import

Just need to provide the target token (TARGET_TOKEN), target user (TARGET_USER), target hostname (TARGET_HOSTNAME) and organization(ORGANIZATION) as env vars.

TARGET_TOKEN=ghp_ENTtokenabc123 \
TARGET_USER=trilom-trailmix \
TARGET_HOSTNAME="github.vms.mud.name" \
ORGANIZATION=trailmix \
  docker buildx bake import

output

Just need to provide the source token (SOURCE_TOKEN), target token (TARGET_TOKEN), target user (TARGET_USER), target hostname (TARGET_HOSTNAME) and organization(ORGANIZATION)

  • Deps:
  • Outputs:
    • Expect the local out directory to contain the ORGANIZATION.tar.gz file and ORGANIZATION-conflicts.csv file.
  • Exceptions:
    • If there are conflicts and there was a failure, you can provide a file to override the derived conflicts file in the conflicts/ directory as ORGANIZATION-conflicts.csv.
SOURCE_TOKEN=ghp_tokenabc123 \
TARGET_HOSTNAME="github.vms.mud.name" \
TARGET_USER=trilom-trailmix \
TARGET_TOKEN=ghp_ENTtokenabc123 \
ORGANIZATION=trailmix \
  docker buildx bake

cleanups

## list all repos in all migrations for an org
curl -H "Authorization: Bearer ghp_tokenabc123" -H "Accept: application/vnd.github+json" https://api.github.com/orgs/trailmix/migrations | jq -e '[.[].repositories[].name]' > repo-names.json
curl -H "Authorization: Bearer ghp_tokenabc123" -H "Accept: application/vnd.github+json" https://api.github.com/orgs/trailmix/migrations | jq -e '[.[].id]' > ids.json

# after two files exist, make a bunch of commands to unlock
echo 'jsonencode([for k,v in setproduct(jsondecode(file("ids.json")),jsondecode(file("repo-names.json"))): format("curl -H \"Authorization: Bearer ghp_tokenabc123\" -X DELETE -H \"Accept: application/vnd.github+json\" https://api.github.com/orgs/trailmix/migrations/%s/repos/%s/lock",v[0],v[1])])' | packer console -config-type=hcl2 | jq -r -e '.[]'

github-migrator's People

Contributors

trilom avatar

Stargazers

 avatar

Watchers

 avatar

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.