I was tasked today to duplicate and import all the GitHub milestones, labels, issues, and comments from one repository to nine other repositories. Of course, as a developer, we would rather spend time searching for or writing code than manually duplicating everything.
- Clean up the destination repository:
- Remove all existing milestones from the destination repository; and
- Remove all existing labels from the destination repository.
- Import the settings of the source repository to the destination repository:
- Import the source milestones to the destination repository;
- Import the source labels to the destination repository; and
- Import, in the order in which they were originally created, the source issues (both open and closed) to the destination repository:
- Create the issue (incl. its title and body and, if any, its assignee, milestone and labels);
- Import the comments associated with the issue, if any; and
- Close the issue, if needed.
What the script does not (either due to GitHub API limitations or GitHub’s ‘features’):
- During the cleaning up of the destination repository, existing issues are not removed. Indeed, once created, an issues simply cannot be deleted.
- Any imported issue can only be created on your behalf rather than that of the original creator (unless it is you!). So, the best we can do, if you are not the original creator, is to edit the issue’s body and mention its original creator.
- As for an imported issue, any comment for an imported issue will be created on your behalf, but as for an imported issue we can, if needed, edit it and mention its original creator.