Skip to content

Instantly share code, notes, and snippets.

@christianc1
Last active June 13, 2018 09:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save christianc1/b3a45d2dcd678d07a752c26541c62b16 to your computer and use it in GitHub Desktop.
Save christianc1/b3a45d2dcd678d07a752c26541c62b16 to your computer and use it in GitHub Desktop.
SFTP Deploys for Pressed with Circle CI

Simple SFTP Deploy when better methods are unavailable by host

Installation

  • npm install --save-dev ftps
  • Add deploy.js to theme/plugin root
  • Add deploy.config.js to theme/plugin root
  • Modify config.

Usage

  • Set up Circle CI with SFTP_HOST SFTP_PASS SFTP_USER environmental variables
  • Push to master
machine:
php:
version: 5.6.17
node:
version: 5.1.0
dependencies:
pre:
- sudo apt-get install -y lftp
deployment:
deploy:
branch: master
commands:
- npm run deploy
module.exports = {
"remote": {
"host": process.env.SFTP_HOST,
"username": process.env.SFTP_USER,
"password": process.env.SFTP_PASS,
"protocol": "sftp",
"directory": "~/wp-content/themes/{theme_name}"
},
"exclude":[
"node_modules/**",
".data/**",
".git/**",
"bin/**",
"*.sh",
"deploy.js",
"*.config.js",
"*.log",
"*.yml",
'.DS_Store'
],
"include": []
};
var FTPS = require('ftps');
var ftpsConfig = require('./deploy.config.js');
var ftps = new FTPS( ftpsConfig.remote );
// Deploy
var stream = ftps.cd( ftpsConfig.remote.directory )
.ls()
.mirror({
remoteDir: '.',
localDir: '.',
options: ftpsConfig.exclude.map( (pattern) => `-X ${pattern}` ).join(' '),
upload: true
})
.ls()
.execAsStream();
stream.pipe(process.stdout);
{
"name": "sftp-pressed-deploy-example",
"scripts": {
"deploy": "node deploy.js"
},
"devDependencies": {
"ftps": "^1.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment