Refactor controller actions to remove duplication
Add environment variables for build