this repo has no description
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

build: organize deploy script part 2

dusk 04fb3473 0833dea0

+20 -4
+20 -4
deploy.nu
··· 4 4 5 5 path add /nix/var/nix/profiles/default/bin 6 6 7 + source-env secrets/deploy-webhook.nu 8 + 9 + def webhook [title: string, content: string, exit_code?: number] { 10 + let type = if $exit_code == null { "⌛" } else if $exit_code == 0 { "✔️" } else { "❌" } 11 + let msg = { 12 + embeds: [{ 13 + description: $content, 14 + title: $"($type) /($title)/", 15 + footer: { 16 + text: $"(date now) \((sys host | get hostname)\)", 17 + } 18 + }] 19 + } 20 + http post --content-type application/json $"https://discord.com/api/webhooks/($env.WEBHOOK_ID)/($env.WEBHOOK_TOKEN)" $msg 21 + } 22 + 7 23 def deploy [hostname: string] { 8 - let hooktitle = $"deploy @ ($hostname)" 24 + let hooktitle = $"/($hostname)/deploy" 9 25 10 26 let start = date now 11 - secrets/deploy-webhook.nu $hooktitle $"=== deploying ($hostname): started ===\n\n(sys disks | to text)\n\n(sys mem | to text)" 27 + webhook $hooktitle $"=== deploying ($hostname): started ===\n\n(sys disks | to text)\n\n(sys mem | to text)" 12 28 13 29 let result = nix run $".#apps.nixinate.($hostname)" -L --show-trace | complete 14 30 let end = date now 15 31 16 32 let paste_url = http post --content-type multipart/form-data "https://0x0.st" {file: ($result | to text | into binary), secret: true} 17 - secrets/deploy-webhook.nu $hooktitle $"=== deployed ($hostname): finished ===\n\ntook ($end - $start)\n\nlog: ($paste_url)" $result.exit_code 33 + webhook $hooktitle $"=== deployed ($hostname): finished ===\n\ntook ($end - $start)\n\nlog: ($paste_url)" $result.exit_code 18 34 } 19 35 20 36 def main [msg?: string] { 21 37 try { 22 38 nix run ".#dns" -- push 23 39 } catch { |err| 24 - secrets/deploy-webhook.nu "dns" $"=== error pushing dns ===\n\n($err | to text)" 1 40 + webhook "dns" $"=== error pushing dns ===\n\n($err | to text)" 1 25 41 } 26 42 27 43 try {