parent
405daae478
commit
c964702143
2 changed files with 44 additions and 1 deletions
@ -0,0 +1,42 @@ |
||||
package MJB::Web::Task::SyncBlog; |
||||
use Mojo::Base 'MJB::Web::Task', -signatures; |
||||
use Mojo::File qw( curfile ); |
||||
use File::Copy::Recursive qw( dircopy ); |
||||
use IPC::Run3; |
||||
|
||||
sub run ( $job, $blog_id ) { |
||||
$job->note( _mds_template => 'build_static' ); |
||||
|
||||
my $build_dir = $job->checkout_repo( $blog_id ); |
||||
my $blog = $job->app->db->blog( $blog_id ); |
||||
|
||||
$job->note( is_clone_complete => 1 ); |
||||
|
||||
# Show the user the commit we're on. |
||||
$job->system_command( [ 'git', '-C', $build_dir->child('src')->to_string, 'log', '-1' ] ); |
||||
|
||||
$build_dir->child('build')->make_path; |
||||
|
||||
$job->system_command( [qw( podman run -ti --rm -v .:/srv/jekyll -e JEKYLL_ROOTLESS=1 docker.io/jekyll/jekyll jekyll build ) ], { |
||||
chdir => $build_dir->child('src')->to_string, |
||||
}); |
||||
|
||||
$job->process_webroot( |
||||
$blog, |
||||
$build_dir->child('src')->child('_site')->to_string, |
||||
$build_dir->child('build')->to_string |
||||
); |
||||
|
||||
$job->note( is_build_complete => 1 ); |
||||
|
||||
my $domain = $blog->domain->name; |
||||
|
||||
foreach my $host ( qw( root@web-west.myjekyllblog.net root@web-east.myjekyllblog.net ) ) { |
||||
$job->system_command( [ qw( rsync -rLptgoD -e ), 'ssh -o StrictHostKeyChecking=no', $build_dir->child('build')->to_string, "$host:/var/www/$domain" ) ] ); |
||||
} |
||||
|
||||
$job->note( is_deploy_complete => 1 ); |
||||
$job->finish( ); |
||||
} |
||||
|
||||
1; |
||||
Loading…
Reference in new issue