clan-core/docs/nix/deploy-docs.nix

50 lines
970 B
Nix
Raw Normal View History

2024-04-12 14:37:50 +00:00
{
writeShellScriptBin,
coreutils,
openssh,
rsync,
lib,
docs,
}:
writeShellScriptBin "deploy-docs" ''
2024-05-04 11:31:30 +00:00
set -eu -o pipefail
2024-04-12 14:37:50 +00:00
export PATH="${
lib.makeBinPath [
coreutils
openssh
rsync
]
}"
2024-05-04 11:31:30 +00:00
#########################################
# #
# DO NOT PRINT THE SSH KEY TO THE LOGS #
# #
#########################################
set +x
2024-04-19 11:54:01 +00:00
if [ -n "''${SSH_HOMEPAGE_KEY:-}" ]; then
2024-04-12 14:37:50 +00:00
echo "$SSH_HOMEPAGE_KEY" > ./ssh_key
chmod 600 ./ssh_key
sshExtraArgs="-i ./ssh_key"
else
sshExtraArgs=
fi
2024-05-04 11:31:30 +00:00
set -x
###########################
# #
# END OF DANGER ZONE #
# #
###########################
2024-04-12 14:37:50 +00:00
rsync \
-e "ssh -o StrictHostKeyChecking=no $sshExtraArgs" \
-a ${docs}/ \
www@clan.lol:/var/www/docs.clan.lol
if [ -e ./ssh_key ]; then
rm ./ssh_key
fi
''