Remove generated file 'frontend.js'
[recipes.git] / deploy.nu
1 def main [host: string, destination: string, ssh_key: path] {
2     let ssh_args = [-i $ssh_key $host]
3     let scp_args = [-r -i $ssh_key]
4     let target = "aarch64-unknown-linux-gnu" # For raspberry pi zero 1: "arm-unknown-linux-gnueabihf"
5
6     def invoke_ssh [command: list] {
7         let args = $ssh_args ++ $command
8         print $"Executing: ssh ($args)"
9         ssh $args
10     }
11
12     def copy_ssh [source: string, destination: string] {
13         let args = $scp_args ++ [$source $"($host):($destination)"]
14         print $"Executing: scp ($args)"
15         scp $args
16     }
17
18     cargo build --target $target --release
19     invoke_ssh [sudo systemctl stop recipes]
20     copy_ssh ./target/($target)/release/recipes $destination
21     invoke_ssh [rm -rf recipes/static]
22     copy_ssh ./backend/static/ $destination
23     copy_ssh ./backend/sql/ $destination
24     invoke_ssh [chmod u+x recipes/recipes]
25     invoke_ssh [sudo systemctl start recipes]
26     print "Deployment finished"
27 }
28