forked from obiba/jira-github-issues
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcleanup_milestones.php
23 lines (18 loc) · 958 Bytes
/
cleanup_milestones.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
require_once 'vendor/autoload.php';
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
$client = new \Buzz\Browser();
$githubHeaders = ['User-Agent: Jira Migration', 'Authorization: token ' . $_SERVER['GITHUB_TOKEN']];
$githubRepository = "dbal";
$response = $client->get('https://api.github.com/repos/' . $_SERVER['GITHUB_ORGANIZATION'] . '/' . $githubRepository . '/milestones?state=all&per_page=100', $githubHeaders);
if ($response->getStatusCode() !== 200) {
printf("Could not fetch existing Github Milestones\n");
var_dump($response->getContent());
exit(3);
}
foreach(json_decode($response->getContent(), true) as $existingMilestone) {
if ($existingMilestone['title'] == '2.5') continue;
$response = $client->delete('https://api.github.com/repos/' . $_SERVER['GITHUB_ORGANIZATION'] . '/' . $githubRepository . '/milestones/' . $existingMilestone['number'], $githubHeaders);
echo($response->getContent()) . "\n";
}