Class: Strata::CLI::SubCommands::Deploy
Constant Summary
Constants included
from Guard
Guard::ALLOWED_COMMANDS
Instance Method Summary
collapse
long_desc_from_file
Methods included from Terminal
#create_spinner, #print_table, #with_spinner
Methods included from Guard
#invoke_command
Instance Method Details
#deploy ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/strata/cli/sub_commands/deploy.rb', line 35
def deploy
config = load_deployment_configuration
validate_deployment_configuration(config)
run_pre_deploy_checks unless options[:skip_audit]
refreshed_imports = refresh_external_imports
branch_id = determine_deployment_branch
run_git_status_checks(branch_id)
confirm_production_deploy(branch_id, config) unless options[:yes]
last_deployment_commit = get_last_successful_deployment_commit(config, branch_id)
local_file_changes = if last_deployment_commit && Utils::Git.git_repo?
Utils::Git.changed_file_paths_since(last_deployment_commit)
else
[]
end
metadata = prepare_deployment_metadata(last_deployment_commit)
if refreshed_imports.any? && local_file_changes.empty?
import_commit_hash = Utils::ImportManager.generate_import_commit_hash(project_path)
say "\nExternal imports change found. Proceeding with deployment", ColorHelper.info
metadata[:commit] = "imports-#{import_commit_hash}"
metadata[:commit_message] = "External imports updated: #{refreshed_imports.map do |c|
File.basename(c[:source])
end.join(", ")}"
end
archive_path = create_and_upload_archive(last_deployment_commit, refreshed_imports: refreshed_imports)
env_display = options[:environment] ? " (#{options[:environment]} environment)" : ""
server_info = config["server"] ? " (#{config["server"]})" : ""
say "\nDeploying to branch '#{branch_id}' on Strata server#{env_display}#{server_info}\n", ColorHelper.info
deployment = submit_deployment(config, branch_id, archive_path, metadata)
monitor_deployment(config, branch_id, deployment)
end
|
#status ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/strata/cli/sub_commands/deploy.rb', line 80
def status
config = load_deployment_configuration
validate_deployment_configuration(config)
branch_id = determine_deployment_branch
client = API::Client.new(config["server"], config["api_key"])
deployment = client.latest_deployment(config["project_id"], branch_id)
unless deployment
say "No deployments found for branch '#{branch_id}'.\n", ColorHelper.info
return
end
deployment_id = deployment["id"]
has_tests = test_files_exist?
monitor = Utils::DeploymentMonitor.new(client, config["project_id"], branch_id, deployment_id,
has_tests: has_tests)
result = monitor.display_status
should_continue_monitoring = if result && !%w[succeeded failed].include?(result["status"])
true
elsif result && result["status"] == "succeeded" && result["stage"] == "finished"
latest_test_run = result["latest_test_run"] || result[:latest_test_run]
has_tests && latest_test_run.nil?
else
false
end
monitor.start(skip_initial_display: true) if should_continue_monitoring
end
|