Last active
September 18, 2019 14:27
-
-
Save niklas-ourmachinery/2d1fc4f8013c11ca410f4983aae32d52 to your computer and use it in GitHub Desktop.
Ruby four-liner for uploading web site from Hugo to FTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# upload.rb URL [SINCE] | |
# | |
# Uploads website generated by Hugo (or other static web site generator) to the URL using wput. | |
# | |
# URL URL of ftp server, including user name and password | |
# (e.g. ftp://USER:[email protected]/public_html/) | |
# | |
# SINCE upload files changed since this git revision | |
# if not specified, HEAD^ is used, i.e. the latest changes are uploaded | |
# | |
# Assumes that generated web pages are checked into git (you probably want to do that | |
# anyway so you can track changes when you update the Hugo version, change layouts, etc). | |
# | |
# Assumes that generated web pages are found in the "public/" directory. | |
URL = ARGV[0] or raise "URL needed (ftp://USER:[email protected]/public_html/)" | |
SINCE = ARGV[1] || "HEAD^" | |
MODIFIED = `git diff --name-only #{SINCE}`.lines.map {|x| x.strip}.select{|x| x[/^public/]}.join(" ") | |
system("wput -u --basename=public/ #{MODIFIED} #{URL}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment