Skip to content

Commit

Permalink
call finish script before deleting oldest release and handle delete e…
Browse files Browse the repository at this point in the history
…rrors sanely
  • Loading branch information
derklaro committed Apr 18, 2023
1 parent 036f72f commit e13d2a6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/handler/finish_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::entity::options::Options;
use crate::handler::call_followup_lifecycle_script;
use crate::handler::release_discard::discord_oldest_release;
use crate::helper::process_helper::CommandResult;
use log::info;
use log::{error, info};
use std::path::Path;
use symlink::{remove_symlink_dir, symlink_dir};

Expand All @@ -13,7 +13,16 @@ pub(crate) async fn finish_deployment(
) -> anyhow::Result<Option<CommandResult>, anyhow::Error> {
let deploy_base_dir = info.base_directory();
let result = internal_finish_deployment(options, info).await;
call_followup_lifecycle_script(&deploy_base_dir, "publish", result).await
let finish_script_result =
call_followup_lifecycle_script(&deploy_base_dir, "publish", result).await;

// cleanup (by removing the oldest release)
info!("Published one release, trying to discord the oldest release");
if let Err(error) = discord_oldest_release(options) {
error!("Unable to delete oldest release: {}", error);
}

finish_script_result
}

async fn internal_finish_deployment(
Expand All @@ -28,9 +37,5 @@ async fn internal_finish_deployment(
remove_symlink_dir(&deployment_link_path).ok();
symlink_dir(deployment_dir, deployment_link_path)?;

// cleanup (by removing the oldest release)
info!("Published one release, trying to discord the oldest release");
discord_oldest_release(options)?;

Ok(())
}

0 comments on commit e13d2a6

Please sign in to comment.