From 73a141316db78b942160b11bdb3c92208f3eddd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 19 Jul 2026 15:06:42 +0200 Subject: Push declaration within a job --- src/Job.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/Job.hs') diff --git a/src/Job.hs b/src/Job.hs index 10fe865..5b88130 100644 --- a/src/Job.hs +++ b/src/Job.hs @@ -18,6 +18,9 @@ module Job ( copyRecursive, copyRecursiveForce, + + currentCommitExpr, + branchExpr, ) where import Control.Concurrent @@ -49,6 +52,7 @@ import System.Posix.Signals import System.Process import Destination +import Expr import Job.Types import Output import Repo @@ -477,6 +481,9 @@ runJob job uses checkoutPath jdir = do , aoutStorePath = target } + forM_ (jobPush job) $ \JobPush {..} -> do + pushToBranch jpushDestination jpushSource + forM_ (jobPublish job) $ \pub -> do Just aout <- return $ lookup (jpArtifact pub) $ map (\aout -> ( ( jobId job, aoutName aout ), aout )) artifacts ++ uses let ppath = case jpPath pub of @@ -489,3 +496,19 @@ runJob job uses checkoutPath jdir = do return JobOutput { outArtifacts = artifacts } + + + +currentCommitExpr :: RepoName -> Expr JobSetContext Commit +currentCommitExpr rname = + addDependency [ RepoDependency rname RepoDepCommit ] $ + (pure getCommit) <*> (lookup (Just rname) . jscRepoRefs <$> GetContext) + where + getCommit = \case + Nothing -> error $ "currentCommitExpr: repo ‘" <> showRepoName rname <> "’ not found" + Just (RepoRefTree _) -> error $ "currentCommitExpr: expected commit in ‘" <> showRepoName rname <> "’, but got a tree" + Just (RepoRefCommit commit) -> commit + Just (RepoRefTag commit _) -> commit + +branchExpr :: RepoName -> Text -> Expr JobSetContext Branch +branchExpr rname bname = pure ((\repo -> Branch repo bname) . fromJust) <*> (lookup (Just rname) . jscRepos <$> GetContext) -- cgit v1.2.3