Skip to content

Commit

Permalink
publish: Remove the published build at the end of the job
Browse files Browse the repository at this point in the history
  • Loading branch information
barthalion committed May 22, 2024
1 parent 58206d0 commit c8ef843
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/jobs/publish_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use serde_json::json;
use std::collections::HashMap;
use std::ffi::OsString;
use std::fs::{self, File};
use std::path::Path;
use std::io::Write;
use std::process::Command;

Expand Down Expand Up @@ -139,6 +140,21 @@ impl PublishJobInstance {

let update_job = schedule_update_job(config, repoconfig, conn, self.job_id)?;

let path = Path::new(&build_repo_path);
job_log_and_info!(
self.job_id,
conn,
&format!("Removing build {}", self.build_id.to_string()),
);

fs::remove_dir_all(path).unwrap_or_else(|_| {
job_log_and_info!(
self.job_id,
conn,
&format!("Failed to remove build")
);
});

Ok(json!({
"refs": commits,
"update-repo-job": update_job.id,
Expand Down

0 comments on commit c8ef843

Please sign in to comment.