# frozen_string_literal: true require "mina/rails" require "mina/git" require "mina/rvm" # for rvm support. (https://rvm.io) require "mina/whenever" require_relative "git_config" require_relative "predeploy" require_relative "tasks" def load_project invoke :before_run unless fetch(:project) end # Shared dirs and files will be symlinked into the app-folder by the # 'deploy:link_shared_paths' step. Some plugins already add folders to # shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many # more run `mina -d` to see all folders and files already included in # `shared_dirs` and `shared_files` set :shared_dirs, fetch(:shared_dirs, []).push( "log", "tmp/pids", "tmp/cache", "tmp/sockets", "bundle", "node_modules", "public/packs", "public/system", "storage" ) set :shared_files, fetch(:shared_files, []).push( "config/database.yml", "config/secrets.yml", "config/master.key" ) # Each deploy, these directories will be checked for changes. If changes are # detected, assets will be precompiled. Otherwise that step will be skipped. set :asset_dirs, ["app/javascript/", "app/packs/"] # This task is the environment that is loaded for all remote run commands, such # as `mina deploy` or `mina rake`. task :environment do # Be sure to commit your .ruby-version to your repository. # For those using RVM, use this to load an RVM version@gemset. # invoke :'rvm:use', 'ruby-1.9.3-p125@default' end task :staging do set :stage, :staging set :rails_env, "staging" end task :production do set :stage, :production set :rails_env, "production" end if ENV["stage"] == "production" invoke :production else invoke :staging end desc "Run predeployment tasks." task predeploy: :remote_environment do load_project run :remote do invoke :setup end invoke :"deploy_configure:create_configs" invoke :"deploy_prepare:create_vhost" invoke :"deploy_prepare:configure_pg" invoke :"deploy_prepare:set_owner" end desc "Deploys the current version to the server." task deploy: :remote_environment do load_project deploy do # Put things that will set up an empty directory into a fully set-up # instance of your project. invoke :rvm_use invoke :checkout_release invoke :link_shared_dirs invoke :"bundle:install" invoke :"rails:db_migrate" invoke :rails, "yarn:install" invoke :rails, "assets:precompile" invoke :"deploy:cleanup" on :launch do invoke(:"whenever:update") if ENV["whenever"] invoke :restart end end invoke :open_browser end