Put the clone method back.

master
Manager Bot 3 years ago
parent 28806d99bf
commit 5d3572d881
  1. 1
      Web/lib/MJB/Web.pm
  2. 14
      Web/lib/MJB/Web/Controller/Blog.pm
  3. 41
      Web/lib/MJB/Web/Task/CreateBlog.pm

@ -43,7 +43,6 @@ sub startup ($self) {
$self->plugin( Minion => { Pg => $self->config->{database}->{minion} } );
# Blog deployment related jobs.
$self->minion->add_task( create_blog => 'MJB::Web::Task::CreateBlog' );
$self->minion->add_task( purge_blog => 'MJB::Web::Task::PurgeBlog' );
$self->minion->add_task( deploy_blog => 'MJB::Web::Task::DeployBlog' );

@ -39,10 +39,7 @@ sub do_create ($c) {
# Create the Jekyll repo for the site
# This is where a job to build it on the build server should happen...
#my $jekyll = $c->jekyll($domain)->init;
my $repo = $c->config->{store_repo_base} . "$domain.git";
my $jekyll = $c->jekyll($domain)->init;
my $blog = try {
$c->db->storage->schema->txn_do( sub {
@ -57,7 +54,7 @@ sub do_create ($c) {
});
$blog->create_related( 'repoes', {
url => $repo,
url => $jekyll->repo,
});
return $blog;
@ -69,13 +66,6 @@ sub do_create ($c) {
# Choose a web server to deploy to
return if $c->stash->{errors};
# Create the blog and add it to git.
my $create_job_id = $c->minion->enqueue( 'create_blog', [ $blog->id ], {
notes => { '_bid_' . $blog->id => 1 },
priority => $blog->build_priority,
});
$blog->create_related( 'builds', { job_id => $create_job_id } );
# Schedule a job to deploy the website
my $ssl_job_id = $c->minion->enqueue( 'create_ssl_cert', [ $blog->id ], {
notes => { '_bid_' . $blog->id => 1 },

@ -1,41 +0,0 @@
package MJB::Web::Task::CreateBlog;
use Mojo::Base 'MJB::Web::Task', -signatures;
use Mojo::File qw( tempdir );
use File::Copy::Recursive qw( dircopy );
sub run ( $job, $blog_id ) {
my $blog = $job->app->db->blog( $blog_id );
$job->note( _mds_template => 'create_blog' );
my $dir = tempdir->make_path;
$job->system_command( [qw( podman run -ti --rm -v .:/srv/jekyll -e JEKYLL_ROOTLESS=1 docker.io/jekyll/jekyll jekyll new blog ) ], {
chdir => $dir->to_string,
});
my $blog_root = $dir->child('blog');
$job->system_command( [ qw( git init ) ], {
chdir => $blog_root->to_string,
});
$job->system_command( [ qw( git remote add origin ), $blog->repo->url ], {
chdir => $blog_root->to_string,
});
$job->system_command( [ qw( git add * ) ], {
chdir => $blog_root->to_string,
});
$job->system_command( [ qw( git commit -m ), "Created blog!" ], {
chdir => $blog_root->to_string,
});
$job->system_command( [ qw( git push origin master ) ], {
chdir => $blog_root->to_string,
});
}
1;
Loading…
Cancel
Save