From d3c830f4efbc7ccf198348d6055681efc2ddf1b5 Mon Sep 17 00:00:00 2001 From: Egor Savkin Date: Mon, 24 Jun 2024 10:57:39 +0800 Subject: [PATCH] Remove temporary files after uploading website Signed-off-by: Egor Savkin --- nixbld-etc-nixos/configuration.nix | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/nixbld-etc-nixos/configuration.nix b/nixbld-etc-nixos/configuration.nix index c54b90c..adfb85a 100644 --- a/nixbld-etc-nixos/configuration.nix +++ b/nixbld-etc-nixos/configuration.nix @@ -7,6 +7,17 @@ let netifWifi = "wlp6s0"; netifSit = "henet0"; hydraWwwOutputs = "/var/www/hydra-outputs"; + deployWebIntl = pkgs.writeShellScript "deployWebIntl" '' + #!${pkgs.bash}/bin/bash + [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] + export "TMPSSH=`mktemp -d`" + trap "rm -rf '$TMPSSH'" EXIT + cp /opt/hydra_id_ed25519 "$TMPSSH/id_ed25519" + cp /opt/hydra_id_ed25519.pub "$TMPSSH/id_ed25519.pub" + echo "5.78.86.156 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEMbV69aqkHdQ1T5lMuALyHjNowU1rottZtEV4OhKQ6Y" > "$TMPSSH/known_hosts" + chmod 600 "$TMPSSH/id_ed25519" + ${pkgs.rsync}/bin/rsync -r -e "${pkgs.openssh}/bin/ssh -i '$TMPSSH/id_ed25519' -o 'UserKnownHostsFile=$TMPSSH/known_hosts' -o IdentitiesOnly=yes" -c $(jq -r '.outputs[0].path' < $HYDRA_JSON)/ zolaupd@5.78.86.156:/var/www/m-labs-intl.com/html/ + ''; in { imports = @@ -653,13 +664,7 @@ in job = web:web:web-intl - command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && export HOME=`mktemp -d` && \ - mkdir $HOME/.ssh && \ - cp /opt/hydra_id_ed25519 $HOME/.ssh/id_ed25519 && \ - cp /opt/hydra_id_ed25519.pub $HOME/.ssh/id_ed25519.pub && \ - echo "5.78.86.156 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEMbV69aqkHdQ1T5lMuALyHjNowU1rottZtEV4OhKQ6Y" > $HOME/.ssh/known_hosts && \ - chmod 600 $HOME/.ssh/id_ed25519 && \ - ${pkgs.rsync}/bin/rsync -r -c $(jq -r '.outputs[0].path' < $HYDRA_JSON) zolaupd@5.78.86.156:/var/www/m-labs-intl.com/html/ + command = ${deployWebIntl} job = web:web:nmigen-docs