npm install --save-dev ftps
- Add
deploy.js
to theme/plugin root - Add
deploy.config.js
to theme/plugin root - Modify config.
- 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" | |
} | |
} |