Code Monkey home page Code Monkey logo

grunt-ssh-deploy's Introduction

grunt-ssh-deploy (Version: 0.2.2)

SSH Deployment for Grunt using ssh2.

Getting Started

This plugin requires Grunt ~0.4.4

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-ssh-deploy --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-ssh-deploy');

The tasks

Overview

In your project's Gruntfile, add a section named environments to the data object passed into grunt.initConfig().

grunt.initConfig({
  environments: {
    environment: {
      // Environment specific options here
    }
  },
});

This plugin will connect to your remote host, add a directory to releases/ in your remote_path, and create a symlink to the latest release.

The symlink by default is current, you can change this by setting current_symlink.

Usage

By setting an environment, you can deploy each specific one with grunt ssh_deploy:environment or rolling back with grunt ssh_rollback:environment.

Options

options.host

Type: String

Remote host to connect to.

options.username

Type: String

The username to connect as on the remote server.

options.password

Type: String

Password for the username on the remote server.

options.privateKey

Type: string

Path to your private key privateKey: require('fs').readFileSync('/path/to/private/key')

options.agent

Type: string

Set agent agent: process.env.SSH_AUTH_SOCK

options.port

Type: String Default value: '22'

Port to connect to on the remote server.

options.deploy_path

Type: String

Full path on the remote server where files will be deployed. No trailing slash needed.

options.local_path

Type: String

Path on your local for the files you want to be deployed to the remote server. No trailing slash needed.

options.current_symlink

Type: String Default value: 'current'

Path to directory to symlink with most recent release.

options.before_deploy, options.after_deploy

Type: String

Commands to run on the server before and after deploy directory is created and symlinked.

Usage Examples

Custom Options

grunt.initConfig({
  // do not store credentials in the git repo, store them separately and read from a secret file
  secret: grunt.file.readJSON('secret.json'),
  environments: {
      staging: {
          options: {
              host: '<%= secret.staging.host %>',
              username: '<%= secret.staging.username %>',
              password: '<%= secret.staging.password %>',
              port: '<%= secret.staging.port %>',
              deploy_path: '/full/path',
              local_path: 'dist',
              current_symlink: 'current',
              debug: true
          }
      },
      production: {
          options: {
              host: '<%= secret.production.host %>',
              username: '<%= secret.production.username %>',
              password: '<%= secret.production.password %>',
              port: '<%= secret.production.port %>',
              deploy_path: '/full/path',
              local_path: 'dist',
              current_symlink: 'current'
          }
      }
  }
});

Before and After Hooks

grunt.initConfig({
  environments: {
    production: {
      host: '123.45.67.89',
      username: 'root',
      password: 'password',
      deploy_path: '/sites/great_project',
      local_path: '.',
      before_deploy: 'cd /sites/great_project/releases/current && forever stopall',
      after_deploy: 'cd /sites/great_project/releases/current && npm install && forever start app.js'
    }
  },
});

Release History

  • 2014/06/23 - v0.2.0 - Added rollback functionality.
  • 2014/06/19 - v0.1.7 - Fixed symlink method to cd into deploy_path before setting symlink.
  • 2014/05/04 - v0.1.5 - Changing symlink method to not use full path.
  • 2014/05/04 - v0.1.0 - Initial release.

grunt-ssh-deploy's People

Contributors

dasuchin avatar matebn avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.