-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1e13e1
commit 86e1c03
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
temp.php |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
define('GITHUB_USER', "<USERNAME>"); | ||
define('GITHUB_TOKEN', "<TOKEN>"); | ||
define('GITHUB_PROJECT', "<PROJECT>"); | ||
|
||
define('LH_TOKEN', "<LH_TOKEN>"); | ||
define('LH_DOMAIN', "<LH_SUBDOMAIN>"); | ||
define('LH_PROJECT_ID', "<LH_PROJECTID>"); | ||
|
||
|
||
|
||
|
||
function setup_curl_github($state) { | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, "http://github.com/api/v2/json/issues/list/".GITHUB_USER."/".GITHUB_PROJECT."/$state"); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
curl_setopt($ch, CURLOPT_USERPWD, GITHUB_USER."/token:".GITHUB_TOKEN); | ||
|
||
$resp = curl_exec($ch); | ||
curl_close($ch); | ||
return $resp; | ||
} | ||
|
||
|
||
function create_lh_issue($params) { | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, "http://".LH_DOMAIN.".lighthouseapp.com/projects/".LH_PROJECT_ID."/tickets.json"); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
curl_setopt($ch, CURLOPT_USERPWD, LH_TOKEN.":x"); | ||
curl_setopt($ch, CURLOPT_POST, true); | ||
|
||
$paramdata = "<?xml version=\"1.0\" encoding=\"UTF-8\"?"."><ticket>"; | ||
foreach($params as $k => $v) { | ||
$paramdata .= "<$k>".htmlspecialchars($v, ENT_QUOTES)."</$k>"; | ||
} | ||
$paramdata .= "</ticket>"; | ||
|
||
curl_setopt($ch, CURLOPT_POSTFIELDS, $paramdata); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | ||
'Content-Type: text/xml', | ||
)); | ||
|
||
$resp = curl_exec($ch); | ||
curl_close($ch); | ||
return $resp; | ||
} | ||
|
||
$github_types = array("open", "closed"); | ||
$lighthouse_types = array( | ||
'open'=>"open", | ||
'closed'=>"resolved", | ||
); | ||
|
||
foreach($github_types as $ghtype) { | ||
|
||
$issuelist = json_decode(setup_curl_github($ghtype)); | ||
|
||
if( count($issuelist->issues)>0) { | ||
foreach($issuelist->issues as $issue) { | ||
// | ||
$params = array( | ||
"title" => $issue->title, | ||
"body" => $issue->body, | ||
"state" => $lighthouse_types[$ghtype], | ||
"tag" => implode(",", $issue->labels), | ||
); | ||
echo create_lh_issue($params); | ||
//print_r($params); | ||
} | ||
} | ||
|
||
} |