nix machine / user configurations

fix(deploy): only git push if any inputs were updated

ptr.pet 4a993cf9 d8587baf

verified
Changed files
+10 -5
+10 -5
deploy.nu
···
return
}
-
try { git push }
webhook $hooktitle $"=== deploy for ($hostname): finished ===" 0 true
}
-
def update-inputs [inputs: list<string>] {
-
let inputsText = $inputs | str join ", "
let stashed = try {
let stash_result = git stash | complete
$stash_result.stdout | str contains "Saved working directory"
···
false
}
log info $"trying to update inputs ($inputsText)"
-
let result = nix run .#nvfetcher -- -f $"\(($inputs | str join '|')\)" | complete
let is_ok = ($result.stdout | str contains "Changes:")
if $is_ok {
let changes_content = $result.stdout | lines | skip until {|line| $line | str contains "Changes:"} | skip 1 | str join "\n"
···
git stash pop
}
}
}
def main [hostname: string = "wolumonde", --only-deploy (-d)] {
webhook "deploy" "=== started deploying ==="
if $only_deploy == false {
-
update-inputs ["blog" "limbusart" "nsid-tracker" "tangled" "headplane"]
try {
log info "trying to update dns records"
nix run ".#dns" -- push
···
}
deploy $hostname
}
···
return
}
webhook $hooktitle $"=== deploy for ($hostname): finished ===" 0 true
}
+
def update-inputs []: list<string> -> bool {
+
let inputsText = $in | str join ", "
let stashed = try {
let stash_result = git stash | complete
$stash_result.stdout | str contains "Saved working directory"
···
false
}
log info $"trying to update inputs ($inputsText)"
+
let result = nix run .#nvfetcher -- -f $"\(($in | str join '|')\)" | complete
let is_ok = ($result.stdout | str contains "Changes:")
if $is_ok {
let changes_content = $result.stdout | lines | skip until {|line| $line | str contains "Changes:"} | skip 1 | str join "\n"
···
git stash pop
}
}
+
$is_ok
}
def main [hostname: string = "wolumonde", --only-deploy (-d)] {
webhook "deploy" "=== started deploying ==="
+
mut inputs_updated = false
if $only_deploy == false {
+
$inputs_updated = ["blog" "limbusart" "nsid-tracker" "tangled" "headplane"] | update-inputs
try {
log info "trying to update dns records"
nix run ".#dns" -- push
···
}
deploy $hostname
+
+
if $inputs_updated {
+
try { git push }
+
}
}