-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReleaseNotes.pl
59 lines (48 loc) · 1.67 KB
/
ReleaseNotes.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# ReleaseNotes.pl
use strict;
use JSON;
use Cwd;
use Data::Dumper;
use FindBin qw( $Bin );
use File::Spec::Functions qw( catfile );
use lib catfile $Bin, 'lib';
use HTML::Template;
use LWP::UserAgent; #this library manages the HTTPS GET request
print "\r\n---TheCrag ReleaseNotes by Paul Hauner---\r\n\r\n";
#The .tmpl template file should be located in the same directory as this script
my $templateFile = getcwd() . '/ReleaseNotes.tmpl';
my $template = HTML::Template->new(filename => $templateFile);
#The response is loaded from github in JSON format
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 } );
my $response = $ua->get("https://api.github.com/repos/theCrag/website/issues?milestone=10&state=closed");
print 'GitHub API GET Response: ' . $response->message . "\r\n\r\n";
if ($response->code != 200) {
die "Exception: Github Response was not 200 OK"
}
#JSON is parsed to the closest available Perl data structure
my $github_raw = decode_json($response->content);
print "Parsing Issues:\r\n";
#enumerate issues
for my $issue (@$github_raw) {
print "-Issue " . $issue->{'id'} . ": " . $issue->{'title'} . "\r\n";
for my $label (keys $issue->{'labels'}) {
print "--Label: " . $issue->{'labels'}[$label]{'name'} . "\r\n";
}
print "\r\n";
}
$template->param(
STUDENT => [
{ NAME => 'NoClimbs', STATUS => 'Closed' },
{ NAME => 'NoUsers' , STATUS => 'Closed' },
]
);
#Debugging Stuff
#print Dumper(@github_raw);
#print @github_raw[0]->'title';
print $github_raw->[0]{'title'} . "\r\n";
#now write the releasenotes file
open(myfile, '>', 'releasenotes.html');
print myfile $template->output;
close(myfile);
#end of script
print "\r\nDone.\r\n";