deploy-to-ovh.fish 850 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/fish
  2. echo 'Deploy website through FTP'
  3. function require
  4. set var $argv[1]
  5. if not set -q $var; or test -z "$var"
  6. echo "Please provide a value for $var"
  7. echo "Did you run the command source against your .env.local?"
  8. exit
  9. end
  10. end
  11. require FTP_HOST
  12. require FTP_USER
  13. require FTP_DEST
  14. require DIST_DIR
  15. set make_dirs (find $DIST_DIR -type d -printf "mkdir $FTP_DEST/%P\n")
  16. set files (find $DIST_DIR -type f)
  17. echo 'Directories to be created :'
  18. echo $make_dirs
  19. echo 'Files to be sent :'
  20. printf %s\n $files
  21. # ftp operation
  22. echo "FTP to $FTP_HOST"
  23. set ftp_sync "put -R $DIST_DIR/* $FTP_DEST"
  24. echo "Format whole command"
  25. printf %s\n $make_dirs $ftp_sync 'bye'
  26. echo "Forward whole command to FTP"
  27. printf %s\n $make_dirs $ftp_sync 'bye' | sftp -P $FTP_PORT $FTP_USER@$FTP_HOST