~mjorgensen/jrgnsn.net

23d5a5a6236938e1dde37dfb06312ca275f1d257 — Matthew Jorgensen 8 months ago 3681a2f
Add ability to display current version
3 files changed, 31 insertions(+), 1 deletions(-)

M _includes/footer.html
M contrib/deploy
A contrib/update_version.rb
M _includes/footer.html => _includes/footer.html +1 -1
@@ 3,6 3,6 @@
    The content for this site is <a
        href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC-BY-NC-SA</a>. The
    <a href="https://git.jrgnsn.net/matthew/jrgnsn.net-old">code</a> for this site is
    <a href="https://opensource.org/licenses/MIT/">MIT</a>.
    <a href="https://opensource.org/licenses/MIT/">MIT</a>. Current version: <a href="https://git.sr.ht/~mjorgensen/jrgnsn.net/commit/{{ site.git_hash }}">{{ site.git_hash }}
  </div>
</footer>

M contrib/deploy => contrib/deploy +16 -0
@@ 1,7 1,23 @@
#!/usr/bin/env bash

PWD=$(pwd)
git_hash=$(git rev-parse --short HEAD)

echo "Working dir: $PWD"

echo
echo "### Updating git hash"
ruby "$PWD/contrib/update_version.rb" "$git_hash"
echo
echo "#### Committing git hash update ####"
git add _config.yml
git commit -m "Updating version to $git_hash"
git push


echo "### Building site ###"
JEKYLL_ENV=production bundle exec jekyll build

echo "### Uploading to the server ###"
sshopts="-o StrictHostKeyChecking=no -i ~/.ssh/mario_rsa"
rsync --rsh="ssh $sshopts" -rP _site/ deploy@jrgnsn.net:/var/www/jrgnsn.net/ --delete
\ No newline at end of file

A contrib/update_version.rb => contrib/update_version.rb +14 -0
@@ 0,0 1,14 @@
require 'yaml'

puts Dir.pwd

new_hash = ARGV[0].to_s

config = YAML.load_file('_config.yml')

puts config['git_hash']
config['git_hash'] = new_hash
File.open('_config.yml', 'w') do |h|
	h.write config.to_yaml
end