Sha256: cb568315835c2a5b7626d4019090cfa88ab5f6a0ee084ba5103351fb5e5da872

Contents?: true

Size: 1.58 KB

Versions: 14

Compression:

Stored size: 1.58 KB

Contents

module Shipit
  class DeploysController < ShipitController
    include ChunksHelper

    before_action :load_stack
    before_action :load_deploy, only: %i(show rollback revert)
    before_action :load_until_commit, only: :create

    def new
      @commit = @stack.commits.by_sha!(params[:sha])
      @commit.checks.schedule if @stack.checks?
      @deploy = @stack.build_deploy(@commit, current_user)
    end

    def show
      respond_to do |format|
        format.html
        format.text { render plain: @deploy.chunk_output }
      end
    end

    def create
      @deploy = @stack.trigger_deploy(
        @until_commit,
        current_user,
        env: deploy_params[:env],
        force: params[:force].present?,
      )
      respond_with(@deploy.stack, @deploy)
    rescue Task::ConcurrentTaskRunning
      redirect_to new_stack_deploy_path(@stack, sha: @until_commit.sha)
    end

    def rollback
      @rollback = @deploy.build_rollback
    end

    def revert
      previous_deploy = @stack.deploys.success.where(until_commit_id: @deploy.since_commit_id).order(id: :desc).first!
      redirect_to rollback_stack_deploy_path(@stack, previous_deploy)
    end

    private

    def load_deploy
      @deploy = @stack.deploys.find(params[:id])
    end

    def load_stack
      @stack ||= Stack.from_param!(params[:stack_id])
    end

    def load_until_commit
      @until_commit = @stack.commits.find(deploy_params[:until_commit_id])
    end

    def deploy_params
      @deploy_params ||= params.require(:deploy).permit(:until_commit_id, env: @stack.deploy_variables.map(&:name))
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
shipit-engine-0.27.1 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.27.0 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.26.0 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.25.1 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.25.0 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.24.0 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.23.1 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.23.0 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.22.0 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.21.0 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.20.1 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.20.0 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.19.0 app/controllers/shipit/deploys_controller.rb
shipit-engine-0.18.1 app/controllers/shipit/deploys_controller.rb