Badge-Depot-Plugin-Githubactions
view release on metacpan or search on metacpan
lib/Badge/Depot/Plugin/Githubactions.pm view on Meta::CPAN
use 5.10.0;
use strict;
use 5.10.1;
use warnings;
use strict;
package Badge::Depot::Plugin::Githubactions;
# ABSTRACT: Github Actions plugin for Badge::Depot
our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
our $VERSION = '0.0100';
use Moose;
use namespace::autoclean;
use Types::Standard qw/Str HashRef Maybe/;
use Path::Tiny;
use JSON::MaybeXS 'decode_json';
with 'Badge::Depot';
has user => (
is => 'ro',
isa => Str,
lazy => 1,
default => sub {
my $self = shift;
if($self->has_meta) {
return $self->_meta->{'username'} if exists $self->_meta->{'username'};
}
},
);
has repo => (
is => 'ro',
isa => Str,
lazy => 1,
default => sub {
my $self = shift;
if($self->has_meta) {
return $self->_meta->{'repo'} if exists $self->_meta->{'repo'};
}
},
);
has branch => (
is => 'ro',
isa => Maybe[Str],
default => sub { undef }
);
has workflow => (
is => 'ro',
isa => Str,
required => 1,
);
has _meta => (
is => 'ro',
isa => HashRef,
predicate => 'has_meta',
builder => '_build_meta',
);
sub _build_meta {
my $self = shift;
return {} if !path('META.json')->exists;
my $json = path('META.json')->slurp_utf8;
my $data = decode_json($json);
return {} if !exists $data->{'resources'}{'repository'}{'web'};
my $repository = $data->{'resources'}{'repository'}{'web'};
return {} if $repository !~ m{^https://(?:www\.)?github\.com/([^/]+)/(.*)(?:\.git)?$};
return {
username => $1,
( run in 1.592 second using v1.01-cache-2.11-cpan-d8267643d1d )