Skip to content

Latest commit

 

History

History
126 lines (87 loc) · 3.52 KB

README.md

File metadata and controls

126 lines (87 loc) · 3.52 KB

shipit-deploy-cd

Test CI Test Coverage Known Vulnerabilities NPM Version

A shipit deployment task without git requirements.

Task is to just copy some local artefacts to a remote location. This is esp. usefull in Continous-Delivery-Scenarios. And that's why the package appended cd. It's using rsync under the hood to only transfer changes and keeps a capristrano like directory structure:

$ tree -L 2
.
├── current -> releases/20190725153703
└── releases
    ├── 20190623143320
    ├── 20190723150429
    ├── 20190724151443
    ├── 20190725152609
    └── 20190725153703

install

a) Install all required packages in one shot:

$ yarn add shipit-cli @uscreen.de/shipit-deploy-cd # or use npm -i

b) Or just add shipit-deploy-cd to any existing setup:

$ yarn add @uscreen.de/shipit-deploy-cd # or use npm -i

...will yield if shipit-cli missing

configure

Add some proper task configuration to your shipitfile.js, example:

// convenience: read app name from it's package.json
const { name } = require('./package.json')

module.exports = shipit => {

  // require and instantiate
  require('@uscreen.de/shipit-deploy-cd')(shipit)

  shipit.initConfig({
    // defaults, every env will inherit from here
    default: {
      dist: 'dist/*', // local source to sync from, can also be an array, like ['public', 'assets']
      deployTo: `/<remote>/<path>/<to>/<deploy>/<to>/${name}`,
      keepReleases: 5 // we keep a copy of last 5 releases
    },

    // example stage server (ssh connection settings)
    stage: {
      servers: '[email protected]'
    },
    
    // example live servers (like above but 2 boxes)
    live: {
      servers: [
        '[email protected]',
        '[email protected]'
        ]
    }
  })

  // convenience: register as 'deploy' task
  shipit.task('deploy', async () => {
    shipit.start('deploy-cd')
  })
}

use

As with all other shipit tasks, this one gets invoked by using the shipit-cli, ie.:

$ shipit stage deploy-cd # or, when registered with another task name
$ shipit stage deploy

Workflow tasks

Following workflow task events are emitted:

  • 'deploy'
  • 'updated'
  • 'published'
  • 'cleaned'
  • 'deployed'

Tests

We use Docker to create a host that shipit-deploy-cd can deploy to during testing.

To start the test host, just run

yarn testhost:start

Attention: Your public SSH keys are read from ~/.ssh/*.pub and transferred to the test host. This is done to allow shipit-deploy-cd to connect to the test host during the tests.

Before you run the tests first time, you may find it useful to ssh to the service once to confirm the authenticity of the used host:

ssh [email protected] -p 2222

Run the tests with

yarn test

Stop the test host by

yarn testhost:stop

Roadmap

  • add api/config docs