summaryrefslogtreecommitdiff
path: root/app/workers/pages_worker.rb
blob: 0c561626f8c5fbd27ea1bb1dd7f5b2c364486cde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

class PagesWorker # rubocop:disable Scalability/IdempotentWorker
  include ApplicationWorker

  sidekiq_options retry: 3
  feature_category :pages
  loggable_arguments 0, 1
  tags :requires_disk_io

  def perform(action, *arg)
    send(action, *arg) # rubocop:disable GitlabSecurity/PublicSend
  end

  # rubocop: disable CodeReuse/ActiveRecord
  def deploy(build_id)
    build = Ci::Build.find_by(id: build_id)
    update_contents = Projects::UpdatePagesService.new(build.project, build).execute
    if update_contents[:status] == :success
      Projects::UpdatePagesConfigurationService.new(build.project).execute
    end
  end
  # rubocop: enable CodeReuse/ActiveRecord

  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
end