class Deploy
Public Instance Methods
deploy(env: nil, repo_ref: nil, dry_run: false, verbose: false, force_local: false)
click to toggle source
# File lib/punt/deploy.rb, line 6 def deploy(env: nil, repo_ref: nil, dry_run: false, verbose: false, force_local: false) dry_run_banner if dry_run environment = punt_environment(env: env) mode = get_mode(environment) mode_opts = mode.mode_opts(environment) repo = get_repo(environment) repo_state = repo.save_state() starting_revision = repo.current_revision_name(short: true) repo_ref = starting_revision unless repo_ref desired_revision = repo.canonical_revision_name(repo_ref, short: true) desired_revision_long = repo.canonical_revision_name(repo_ref, short: false) if (repo.any_uncommited_changes?) if force_local puts "There are uncommitted changes! We're going to try and deploy anyway because the --force-local flag was present" else raise "There are uncommitted changes! Run `git status` to view the uncommitted files. Commit all of your changes, so that the deploy comes from a specific git revision. To force a deploy using these local changes use the parameter --force-local and don't specify a specific commit ref" end end puts "Deploying #{desired_revision} to #{env}" puts "" # Checkout the code if desired_revision != starting_revision repo.checkout_revision(desired_revision, dry_run: dry_run) end # Mode Logistics mode.mode_start(mode_opts: mode_opts, dry_run: dry_run, verbose: verbose) # Upload Starting File mode.upload_versionfile(desired_revision_long, "start", mode_opts: mode_opts, verbose: verbose ) unless dry_run # Upload Files mode.transfer_start(mode_opts: mode_opts, dry_run: dry_run, verbose: verbose) if environment["files"] environment["files"].each do |key, value| mode.transfer(key, value, mode_opts: mode_opts, dry_run: dry_run, verbose: verbose) end end mode.transfer_complete(mode_opts: mode_opts, dry_run: dry_run, verbose: verbose) # Upload Success File mode.upload_versionfile(desired_revision_long, "success", mode_opts: mode_opts, verbose: verbose ) unless dry_run # Revert to our previous checkout if desired_revision != starting_revision repo.restore_state(repo_state, dry_run: dry_run) end end