Skip to content

Commit

Permalink
Set FLAT_MANAGER_BUILD_ID in publish hook
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswestman authored and barthalion committed Jul 19, 2023
1 parent 4d5f01a commit ba68a63
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ config file; see `example-config.json`.

The publish hook runs in the build directory before a build is published
to a main repository. It can modify the build, for example by rewriting
the appstream files in the commits.
the appstream files in the commits. It receives the `FLAT_MANAGER_IS_REPUBLISH`
environment variable, which is `true` if the publish was triggered by the
republish endpoint or `false` if the publish is part of a build.
If the publish is part of the build, the hook also receives the
`FLAT_MANAGER_BUILD_ID` environment variable.

Check scripts are run after a build is uploaded. Builds may not be
published unless all checks have passed. The check is marked as failed
Expand Down
6 changes: 5 additions & 1 deletion src/jobs/publish_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ impl PublishJobInstance {
let build_repo_path = config.build_repo_base.join(self.build_id.to_string());

// Run the publish hook, if any
if let Some(hook) = repoconfig
if let Some(mut hook) = repoconfig
.hooks
.publish
.as_ref()
.and_then(|x| x.build_command(&build_repo_path))
{
job_log_and_info!(self.job_id, conn, "Running publish hook");

hook.env("FLAT_MANAGER_IS_REPUBLISH", "false");
hook.env("FLAT_MANAGER_BUILD_ID", build.id.to_string());

do_command(hook)?;
}

Expand Down
5 changes: 4 additions & 1 deletion src/jobs/republish_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@ impl JobInstance for RepublishJobInstance {
}

// Run the publish hook, if any
if let Some(hook) = repoconfig
if let Some(mut hook) = repoconfig
.hooks
.publish
.as_ref()
.and_then(|x| x.build_command(tmp_repo_dir.path()))
{
job_log_and_info!(self.job_id, conn, "Running publish hook");

hook.env("FLAT_MANAGER_IS_REPUBLISH", "true");

do_command(hook)?;
}

Expand Down

0 comments on commit ba68a63

Please sign in to comment.