Sha256: 91963e850557ccb8e2d978cba665a0035eda7226deac1fa4bb2146fe14e37670

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'dandelion/deployment'
require 'dandelion/service'
require 'yaml'

module Dandelion
  class << self
    def run
      unless File.exists? '.git'
        puts 'Not a git repository: .git'
        exit
      end

      unless File.exists? 'deploy.yml'
        puts 'Could not find file: deploy.yml'
        exit
      end

      config = YAML.load_file 'deploy.yml'

      if config['scheme'] == 'sftp'
        service = Service::SFTP.new(config['host'], config['username'], config['password'], config['path'])
      else
        puts "Unsupported scheme: #{config['scheme']}"
        exit
      end

      puts "Connecting to:   #{service.uri}"

      begin
        # Deploy changes since remote revision
        deployment = Deployment::DiffDeployment.new('.', service, config['exclude'])

        puts "Remote revision:  #{deployment.remote_revision}"
        puts "Local revision:   #{deployment.local_revision}"

        deployment.deploy
      rescue Deployment::RemoteRevisionError
        # No remote revision, deploy everything
        deployment = Deployment::FullDeployment.new('.', service, config['exclude'])

        puts "Remote revision:  ---"
        puts "Local revision:   #{deployment.local_revision}"

        deployment.deploy
      end

      puts "Deployment complete"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dandelion-0.1.1 lib/dandelion.rb