Created
January 3, 2012 08:33
-
-
Save arunthampi/1554094 to your computer and use it in GitHub Desktop.
Set Asset Fingerprint as part of the deployment workflow
This file contains hidden or 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
def set_asset_fingerprint! | |
# -- First see if the files have changed | |
puts "-----> Calculating Asset Fingerprint" | |
fingerprint_method = "find public -type f -exec md5 {} + | awk '{print $0}' | sort | md5" | |
current_fingerprint = %x{#{fingerprint_method}} | |
fingerprint_file = Rails.root.join('assets.fingerprint') | |
if !File.exists?(fingerprint_file) || current_fingerprint != File.read(fingerprint_file) | |
execute("#{fingerprint_method} > #{fingerprint_file}") | |
# -- Add it to production | |
execute("git add #{fingerprint_file}") | |
# -- Commit it to production | |
execute("git commit -m 'Generating new asset fingerprint at #{DateTime.now.inspect}'") | |
puts "-----> Committing new assets fingerprint --> #{File.read(fingerprint_file)}" | |
end | |
puts "-----> Asset Fingerprint is #{File.read(fingerprint_file)}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment