# frozen_string_literal: true require "yaml" require "json" require "groundskeeper/project" require "groundskeeper/document" require "groundskeeper/git" require "groundskeeper/executable" desc "Sets up project details." # rubocop:disable Metrics/BlockLength task :before_run do application = %x(basename `git rev-parse --show-toplevel`).strip! unless Groundskeeper::Project.available_applications.include? application raise "must be inside application repo (currently in #{application}). " \ "available applications: " + Groundskeeper::Project.available_applications end project = Groundskeeper::Project.build(application) set :project, project set :application_name, application set :domain, project.full_dns(fetch(:stage)) set :user, "deploy" set :repository, project.repo_url set :repo_name, project.repo_name set :deploy_to, project.deploy_to set :forward_agent, true set :bundle_path, "bundle" set :smtp_domain, project.smtp_domain set :rvm_ruby_version, project.rvm_ruby_version set :rvm_type, :system # On each deploy, prompt for the tag puts "Looking up tags for project #{application}... (#{project.repo_url})" tags = project.tags raise "There must be a tagged release prior to deploying." if tags.count.zero? tag = ENV["tag"] unless tags.include? tag raise "Tag \"#{tag}\" not found. Available tags:\n #{tags.join("\n")}" end set :branch, "master" set :tag, tag set :nginx, fetch(:nginx) end # rubocop:enable Metrics/BlockLength