@@ -42,21 +42,30 @@ deployPush deployPath = do
4242 callProcess "ssh-add" [deployPath </> "ssh_key"]
4343 host <- fmap (T.unpack . T.strip) $ T.readFile $ deployPath </> "backend_hosts"
4444 let srcPath = deployPath </> "src"
45+ build = do
46+ buildOutput <- nixBuild $ def
47+ { _nixBuildConfig_target = Target
48+ { _target_path = srcPath
49+ , _target_attr = Just "server"
50+ }
51+ , _nixBuildConfig_outLink = OutLink_None
52+ , _nixBuildConfig_args = pure $ Arg "hostName" host
53+ }
54+ return $ listToMaybe $ lines $ buildOutput
4555 result <- readThunk srcPath >>= \case
4656 Right (ThunkData_Packed _) -> do
4757 unpackThunk srcPath
48− let build = do
49− buildOutput <- nixBuild $ def
50− { _nixBuildConfig_target = Target
51− { _target_path = srcPath
52− , _target_attr = Just "server"
53− }
54− , _nixBuildConfig_outLink = OutLink_None
55− , _nixBuildConfig_args = pure $ Arg "hostName" host
56− }
57− return $ listToMaybe $ lines $ buildOutput
5858 result <- build `finally` packThunk srcPath "origin" -- get upstream
5959 return result
60+ Right (ThunkData_Checkout _) -> do
61+ checkGitCleanStatus srcPath >>= \case
62+ True -> do
63+ result <- build
64+ packThunk srcPath "origin" -- get upstream
65+ return result
66+ False -> do
67+ _ <- fail $ "ob deploy push: ensure " <> srcPath <> " has no pending changes and latest is pushed upstream."
68+ return Nothing
6069 _ -> return Nothing
6170 forM_ result $ \res -> do
6271 callProcess "nix-copy-closure" ["-v", "--to", "root@" <> host, "--gzip", res]