Migrating a GitHub Organization with CasperJS + PhantomJS
Overview
When migrating a GitHub Enterprise Organization, I drove the operation through a headless browser using CasperJS and PhantomJS.
Since there is no API for this on GitHub (I think?), I went with this approach.
To be honest, I had been enjoying building browser-based tests with CasperJS + PhantomJS, and since it just worked when I tried it, that’s how I ended up adopting it.
What is a headless browser?
It’s a browser without a GUI that you use from the CLI.
It still has the features you’d expect for front-end testing, such as rendering pages, loading images, and logging in.
Three-line summary
- Run the transfer process through browser operations, including login authentication, with CasperJS + PhantomJS
- After the migration, verify that the original URL redirects to the destination
- If the expected element can’t be obtained within the time limit, capture the page
Let’s try it
Please refer to Get Started.
The steps are also summarized below.
Clone
1 | macOS%$ git clone https://github.com/kenzo0107/ghe-org-transfer |
Edit the <your ****> parts in scripts/ghe-org-transfer.js
1 | var config = { |
Migration example
- ex) hoge/mywonderfulrepo —> moge/mywonderfulrepo
1 | paths: [ |
You can specify multiple entries in paths without any issues.
Running the migration
1 | macOS%$ make run |
- Execution result
- Note: After the migration, it tests whether the original URL redirects.
1 | [url] https://github.aiueo.com/hoge/mywonderfulrepo/settings |
Wrap-up
Previously, the Grafana API for taking snapshots of Grafana graphs didn’t work well, but I was able to capture them with CasperJS + PhantomJS instead.
Wow, so handy ♪
On a completely unrelated note, I tried challenges like getting past the reCAPTCHA used for site authentication, but couldn’t make it work…
If anyone has pulled it off, please let me know m(_ _)m

