Skip to content

Instantly share code, notes, and snippets.

@predominant
Created November 16, 2012 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save predominant/4087697 to your computer and use it in GitHub Desktop.
Save predominant/4087697 to your computer and use it in GitHub Desktop.
Github to Redmine Import
<?php
// Github Details
$github_org = 'predominant';
$github_repo = 'TwigView';
$github_user = 'user';
$github_password = 'pass';
// Get from Github
$issues_url = "https://api.github.com/repos/$github_org/$github_repo/issues?state=open";
$json = file_get_contents($issues_url);
$data = json_decode( $json, true );
// Push to Redmine
var_dump($data);
foreach ( $data as $row ) {
$subject = $row['title'];
$description = $row['body'];
// $issue = new Issue(
// array(
// 'subject' => $subject,
// 'description' => $description,
// 'project_id' => 'vt1', // Project ID of Vtesse Website
// 'assigned_to_id' => 3, //User ID of Will
// 'status_id' => 5, //Status ID for CLOSED
// )
// );
// $issue->save();
echo $issue['id'] . 'created successfully<br />';
$issue_id = $issue['id'];
// Add comments as updates
if ($row['comments'] > 0 ) {
$commentid = $row['number'];
$comment_url = "https://api.github.com/repos/$github_org/$github_repo/issues/$commentid/comments";
$json2 = file_get_contents( $comment_url );
$comments = json_decode( $json2, true );
foreach ( $comments as $comment_row ) {
$comment_notes = $comment_row['body'];
// $issue->find( $issue_id );
// $issue->set( 'notes', $comment_notes )->save();
echo 'Comment added';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment