How to schedule and publish a post after it’s ready?

There might be two ways:

add_action( 'draft_post', 'wpse_246730_my_function' );
function wpse_246730_my_function( $post_id, $post )
{
    // Do your things

    // Just to stay safe
    remove_action( 'draft_post', 'wpse_246730_my_function' );
    wp_publish_post( $post_id );
    add_action( 'draft_post', 'wpse_246730_my_function' );
}

Or make the post future status, and set a time after 10 or 20 mins to publish. Then use the following code:

add_action( 'future_post', 'wpse_246730_my_function' );
function wpse_246730_my_function( $post_id, $post )
{
    // Do your things
}