Class: Statixite::DeploymentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/statixite/deployments_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/statixite/deployments_controller.rb', line 9

def create
  GitService.new(@site.site_clone_path, @site.site_remote).clone_or_open
  if @site.update(site_params)
    ds = DeploymentService.new(@site).deploy
    if ds.successful?
      flash[:notice] = "Deployment successful! Please allow for up to 15 minutes for changes to be synced up."
      redirect_to site_deployments_path(@site)
    else
      flash[:alert] = ds.error_message
      redirect_to site_deployments_path(@site)
    end
  else
    @deployment = Deployment.new
    render :index
  end
end

#exportObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/statixite/deployments_controller.rb', line 26

def export
  @deployment = @site.deployments.find(params[:deployment_id])
  FileUtils.mkdir_p(Rails.root.join("tmp", "statixite_zips").to_s)
  zip_tmp = Rails.root.join("tmp", "statixite_zips", "#{@site.statixite_name}-#{@deployment.created_at}.zip")
  gs =GitService.new(@site.site_build_path, @site.site_remote).clone_or_open
  begin
    gs.checkout('statixite_build')
    gs.object(@deployment.sha).archive(zip_tmp.to_s, :format => 'zip')
    success = true
  rescue Git::GitExecuteError => e
    Rais.logger.error e
    success = false
  end
  if success
    respond_to do |format|
      format.zip do
        send_file zip_tmp, filename: "#{@site.statixite_name}-#{@deployment.created_at}.zip" 
      end
    end
  else
    flash[:alert] = 'Something went wrong. Please notify support.'
    redirect_to site_deployments_path(@site)
  end
end

#indexObject



5
6
7
# File 'app/controllers/statixite/deployments_controller.rb', line 5

def index
  @deployment = Deployment.new
end