Sha256: 069ff858618f640b75049c07e9612206190843622642079b286dacbe2d48efbb

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

namespace :deploy do
  # TODO: append files to symlinked at stage?

  def env_file_is_okay?(file)
    # TODO: check env file content
    File.exist?(file)
  end

  def warning_env_file_not_found(file)
    info "The #{file} was not specified or not found."
  end

  def upload_env_file(file)
    to_path = "#{shared_path}/#{File.basename(file)}"
    info "deploying #{file} => #{to_path}"
    upload! file, to_path
  end

  desc "Upload .env files to remote server"
  task :dotenv_upload do
    # TODO: move to namespace load task defaults?
    # TODO: if both files are equal (have equal content) check
    env_file = fetch(:env_file, ".env")
    stage_env_file = fetch(:stage_env_file, ".env.#{fetch(:stage)}")

    on roles(:all) do
      [env_file, stage_env_file].each do |file|
        if env_file_is_okay?(file)
          upload_env_file(file)
        else
          warning_env_file_not_found(file)
        end
      end
    end
  end

  before 'deploy:symlink:shared', 'deploy:dotenv_upload'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano3-dotenv-upload-0.1.3 lib/capistrano3/dotenv/upload/upload.rake