Sass on Heroku or any generated files for that matter

May 11, 2011 22:34

Here’s yet another take on how to handle generated files when you are deploying to Heroku while keeping your git repo free of the artifacts.

We deploy using a rake task rake deploy that was generating Jammit files, committing them to the repo and pushing them up. This works fine, but adds “junk” commits to your repo and even the occasional merge conflict from the generated files.

Since Heroku doesn’t care what you push to it as long as it is in the master branch on their end, why not generate the assets in a throwaway branch and push that up?

Here are the basic commands you would run in the shell. Wrap them up in a rake task that fits your project and off you go.

# send it up to github
git push origin master 

# get rid of the branch if it exists (it shouldn't)
git branch -D deploy

# generate Jammit, Sass, etc. files
rake cache_assets 

# push it up to heroku, need force since it's a different branch every time
git push heroku deploy:master --force 

git checkout master

# get rid of the old branch
git branch -D deploy 

As long as everybody uses the rake task to deploy you shouldn’t have any problems with this technique.

Comments

None yet...

Add a comment