#+title: Mirroring forge from phab to github
#+author: ardumont
* Need
- the first step is writing a script that takes the URL (or ID) of
*one* of our repos, and does the entire mirroring setup using the
github API and the phabricator API
- having that script will also make it easy to maintain the sync in
the future when we create new repos
* (github) API token
generation and setup?
https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization
* (forge) API token
generation: https://forge.softwareheritage.org/settings/user/ardumont/page/apitokens/
No setup needed, the token will be passed along to the command.
* (github) Create a public repository
With the same name as in phabricator:
https://developer.github.com/v3/repos/#create
* (forge) Edit repository URI
Edit the repository settings on forge.softwareheritage.org:
- Manage repository > URIs (see below for api call)
- Edit the credentials for that new uri to be K2
Values:
- Uri: github's ui
- I/O type: Mirror
- Display type: Hidden
Equivalent api call: https://forge.softwareheritage.org/conduit/method/diffusion.uri.edit/
|------------+---------------------------------------------------------------------------------------------------------------------------------------------------------|
| parameter | Description |
|------------+---------------------------------------------------------------------------------------------------------------------------------------------------------|
| repository | Create a URI in a given repository. This transaction type must be present when creating a new URI and must not be present when editing an existing URI. |
| uri | Change the repository URI. |
| io | Adjust I/O behavior. |
| display | Change display behavior. |
| credential | Change the credential for this URI. |
| disable | Disable or activate the URI. |
|------------+---------------------------------------------------------------------------------------------------------------------------------------------------------|
Note: For a repository: https://forge.softwareheritage.org/conduit/method/diffusion.repository.edit/
A sample call would then be.
#+BEGIN_SRC sh
API_TOKEN="" # token generated in setup phase
REPOSITORY="" # repository concerned by the mirroring
GITHUB_URI="" # github's mirror repository uri
curl https://forge.softwareheritage.org/api/diffusion.uri.edit \
-d api.token=$API_TOKEN \
-d uri=$GITHUB_URI \
-d io=Mirror \
-d display=Hidden \
-d credential=K2
#+END_SRC
* (github)
Disable wiki/issues page.
api call?
* Integration test
- [ ] Create a dumb repository in phab's forge
- [ ] Trigger the script for that repository
- [ ] check results on github. Is the repository mirrored?
- [ ] Check results in forge. Is the repository's original uri ok?
- [ ] Push a new commit and push through forge
- [ ] Is that commit pushed on github's mirror?