Class: Deployme::Notifications::Github
Class Method Summary
collapse
Instance Method Summary
collapse
all, defaults, #initialize
Class Method Details
.options(parser) ⇒ Object
7
8
9
|
# File 'lib/deployme/notifications/github.rb', line 7
def self.options(parser)
parser.on('--github-token=NAME', String, 'GitHub Token to send Deployments') { |options, value| options.github_token = value }
end
|
Instance Method Details
#notify_error(error = nil) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/deployme/notifications/github.rb', line 31
def notify_error(error = nil)
return unless @github_deployment
logger.error 'Reporting Error to GitHub'
response = request(
:post,
"https://api.github.com/repos/appearhere/web/deployments/#{@github_deployment['id']}/statuses",
state: 'error',
description: error.to_s[0...140]
)
return if response['id']
logger.error response['message']
end
|
#notify_finish ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/deployme/notifications/github.rb', line 45
def notify_finish
return unless @github_deployment
logger.info 'Successful GitHub Deployment...'
request(
:post,
"https://api.github.com/repos/appearhere/web/deployments/#{@github_deployment['id']}/statuses",
state: 'success',
environment_url: deployment.options.deploy_url,
description: 'Review app created successfully.'
)
end
|
#notify_start ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/deployme/notifications/github.rb', line 11
def notify_start
logger.info 'Create GitHub Deployment...'
return if options.dry_run
@github_deployment = request(
:post,
'https://api.github.com/repos/appearhere/web/deployments',
ref: deployment.options.git_commit,
environment: deployment.environment,
auto_merge: false,
transient_environment: deployment.environment != 'production',
production_environment: deployment.environment == 'production',
required_contexts: []
)
return if @github_deployment['id']
logger.error 'Failed to create GitHub Deployment'
logger.error @github_deployment['message']
raise
end
|