use strict; use warnings; # by bliako on 27/05/2019 # creates a new git repository if it does not exist # requires git username, login and password which is # read from command line. use Net::GitHub; use Data::Dumper; my $github_reponame = 'new-repo'; my $github_login = ''; my $github_username = '...'; print "$0 : enter password for '$github_login': "; my $github_password = ; chomp($github_password); my $git = Net::GitHub->new( login => $github_username, pass => $github_password ); 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 me", }) }; if( $@ ){ print STDERR "$0 : failed to create repository '$github_reponame' : $@\n"; exit(1) } }