Skip to content

Instantly share code, notes, and snippets.

@RogerTangos
Last active July 13, 2021 15:07
Show Gist options
  • Save RogerTangos/28ffdee85ec1a3864f85a98ba2c9f4cc to your computer and use it in GitHub Desktop.
Save RogerTangos/28ffdee85ec1a3864f85a98ba2c9f4cc to your computer and use it in GitHub Desktop.
Migrate github issues to clubhouse
# Here's a little python script for migrating github issues to clubhouse
# Uses the https://pypi.org/project/PyGithub/ and https://pypi.org/project/clubhouse/ api wrappers
# PyGithub is GNU Library or Lesser General Public License (LGPL) licensed.
from github import Github
from clubhouse import ClubhouseClient
g = Github("<access_token>")
clubhouse = ClubhouseClient("<api_key>")
repos = g.get_user().get_repos()
myrepo = [x for x in repos if '<myrepo_name>' in x.full_name][0]
issues = myrepo.get_issues(state='open')
issues = [x for x in issues if not x.pull_request]
for issue in issues:
name = issue.title
issue.user.login
description = "issue opener: [" + issue.user.login + "](https://github.com/" + issue.user.login + ")\n" + issue.body
external_id = "https://github.com/parcelLab/Backend/issues/" + str(issue.number)
comments = issue.comments
labels = issue.labels
label_arr = []
for label in labels:
label_name = label.name
color = label.color
label_url = label.url
label_arr.append({'color': "#" + color, 'name': label_name, 'external_id': label_url})
comments = issue.get_comments()
comment_arr = []
for comment in comments:
author_id = comment.user.login
text = "actual author: [" + author_id + "](https://github.com/" + author_id + ")\n" + comment.body
created_at = comment.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")
comment_arr.append({'created_at': created_at, 'external_id': '', 'text': text})
story = {'name': name, 'description': description, 'project_id': 68, 'external_id': external_id, 'labels': label_arr, 'comments': comment_arr}
clubhouse.post('stories', json=story)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment