I’d like to learn how to build a rake task for my rails 3 app that does two things.
- Pushes assets to the CDN
- Deploys to heroku
Commands for the above steps:
rake cache:s3
heroku jammit:deploy --app #{app}
Here’s what I have /lib/tasks/deployer.rake
task :deployit do
puts '=== Storing assets on s3 ==='
run "rake cache:s3"
puts '=== Deploying to Heroku ==='
run "heroku jammit:deploy --app #{app}"
end
def run(cmd)
shell cmd
if $?.exitstatus == 0
display "[OK]"
else
display "[FAIL]"
end
end
But that errors with ‘undefined method `shell’ for main:Object’
Suggestions on how to make this work? Should this be a task or something else?
Thanks
The first task is another rake task, which will run if it is a dependency of the
:deployittask. Your current code would loads rake twice.If you use system like Arun suggested you would get: