2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
class PagesWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 11:08:30 -05:00
|
|
|
include ApplicationWorker
|
2015-11-03 15:28:07 -05:00
|
|
|
|
2021-07-21 08:09:35 -04:00
|
|
|
data_consistency :always
|
|
|
|
|
2018-03-05 07:57:48 -05:00
|
|
|
sidekiq_options retry: 3
|
2019-10-18 07:11:44 -04:00
|
|
|
feature_category :pages
|
2020-06-12 08:08:56 -04:00
|
|
|
loggable_arguments 0, 1
|
2021-07-27 23:08:41 -04:00
|
|
|
worker_resource_boundary :cpu
|
2015-11-03 15:28:07 -05:00
|
|
|
|
2015-12-18 07:07:53 -05:00
|
|
|
def perform(action, *arg)
|
2017-08-03 22:20:34 -04:00
|
|
|
send(action, *arg) # rubocop:disable GitlabSecurity/PublicSend
|
2015-12-18 07:07:53 -05:00
|
|
|
end
|
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2015-12-18 07:07:53 -05:00
|
|
|
def deploy(build_id)
|
2016-01-15 06:21:52 -05:00
|
|
|
build = Ci::Build.find_by(id: build_id)
|
2020-07-29 14:09:50 -04:00
|
|
|
update_contents = Projects::UpdatePagesService.new(build.project, build).execute
|
|
|
|
if update_contents[:status] == :success
|
|
|
|
Projects::UpdatePagesConfigurationService.new(build.project).execute
|
2016-02-09 12:06:55 -05:00
|
|
|
end
|
2015-12-16 10:29:53 -05:00
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2015-11-03 15:28:07 -05:00
|
|
|
|
2015-12-18 07:07:53 -05:00
|
|
|
def remove(namespace_path, project_path)
|
|
|
|
full_path = File.join(Settings.pages.path, namespace_path, project_path)
|
|
|
|
FileUtils.rm_r(full_path, force: true)
|
|
|
|
end
|
2015-11-03 15:28:07 -05:00
|
|
|
end
|