Created
March 1, 2023 14:07
-
-
Save tadas-s/eab673f237ff5384027bb3e21e641cf9 to your computer and use it in GitHub Desktop.
git post-update hook for building Rails app pushed over ssh into a bare VM
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
#!/usr/bin/sh | |
project_name="project-name-here" | |
project_root="${HOME}" | |
refname=${1} | |
rev=$(git rev-parse --short ${1}) | |
this_release="${project_root}/${project_name}-${rev}" | |
mkdir -p ${this_release} | |
git archive ${refname} | tar -x -C ${this_release} | |
echo "${project_name}-${rev}" > "${this_release}/.ruby-gemset" | |
pushd ${this_release} | |
rvm gemset globalcache enable | |
rvm-shell -c "gem install bundler" | |
rvm-shell -c "bundle config set --local without 'development test'" | |
rvm-shell -c "bundle install" | |
cp --recursive "${project_root}/${project_name}/public/assets" "${this_release}/public/" | |
rvm-shell -c "bundle exec rake assets:precompile" | |
rvm-shell -c "rails assets:clean[5]" | |
popd | |
ln -sfn ${this_release} "${project_root}/${project_name}" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment