You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.6 KiB
54 lines
1.6 KiB
package MJB::Web::Task::DeployBlog;
|
|
use Mojo::Base 'MJB::Web::Task', -signatures;
|
|
use Mojo::File qw( curfile );
|
|
use File::Copy::Recursive qw( dircopy );
|
|
use IPC::Run3;
|
|
|
|
sub run ( $job, $site_id ) {
|
|
$job->note( _mds_template => 'build_static' );
|
|
|
|
my $build_dir = $job->checkout_repo( $site_id );
|
|
my $site = $job->app->db->site( $site_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(
|
|
$site,
|
|
$build_dir->child('src')->child('_site')->to_string,
|
|
$build_dir->child('build')->to_string
|
|
);
|
|
|
|
#==
|
|
# Build Site Config
|
|
#== TODO: There is two different files made here, one is done by ansible -- pick one,
|
|
# probably this one.
|
|
Mojo::File->new($build_dir)->child('build')->child('site.yml')->spurt(
|
|
YAML::Dump({
|
|
domain => $site->domain->domain,
|
|
www_dir => "$build_dir/build/",
|
|
})
|
|
);
|
|
|
|
$job->note( is_build_complete => 1 );
|
|
|
|
# Go to the build directory and make $build_dir/.
|
|
$ENV{MARKDOWNSITE_CONFIG} = Mojo::File->new($build_dir->to_string)->child('build')->child('site.yml');
|
|
$job->system_command( [ 'ansible-playbook', '/etc/ansible/deploy-website.yml' ] );
|
|
|
|
|
|
$job->note( is_deploy_complete => 1 );
|
|
$job->finish( );
|
|
|
|
}
|
|
|
|
1;
|
|
|