Created
November 16, 2012 14:22
-
-
Save predominant/4087697 to your computer and use it in GitHub Desktop.
Github to Redmine Import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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