#!/usr/bin/perl use 5.011; use warnings; # original by bliako on 27/05/2019 PM node_id=11100309 ## embellishments don't work yet use Net::GitHub; use Data::Dumper; use Config::Tiny; my $ini_path = qw( /home/bob/Documents/html_template_data/3.values.ini ); say "ini path is $ini_path"; my $sub_hash = "my_github"; my $Config = Config::Tiny->new; $Config = Config::Tiny->read( $ini_path, 'utf8' ); say Dumper $Config; # -> is optional between brackets my $github_login = $Config->{$sub_hash}{'email'}; my $github_username = $Config->{$sub_hash}{'username'}; my $github_password = $Config->{$sub_hash}{'password'}; say "login is $github_login"; say "password is $github_password"; print "$0 : enter value for reponame: "; my $github_reponame = ; chomp($github_reponame); my $git = Net::GitHub->new( login => $github_username, pass => $github_password ); say "username is $github_username"; my $reposinfo = $git->repos->list($github_username); print Dumper($reposinfo); my %reposlist = map { lc $_->{'full_name'} =~ s|^${github_username}/||r => $_ } @$reposinfo; print "Repos: " . join( ",", keys %reposlist ) . "\n"; if ( !defined $reposlist{ lc $github_reponame } ) { print "$0 : creating new repository '$github_reponame' ...\n"; my $ret = undef; eval { $ret = $git->repos->create( { name => $github_reponame, description => "change this to suit", } ); }; if ($@) { print STDERR "$0 : failed to create repository '$github_reponame' : $@\n"; exit(1); } } __END__