This is just to give you a hint to the way to a solution. It´s not a detailed step by step answer.
If alredy using Grunt, you can use this grunt plugin.
It´s a wrapper of the msdeploy.exe command so you need to learn about that here.
Before all of this you need to install Web Deploy on your server. There are serveral strats and posts about this. I choosed using the Remote Agent way.
I manually create the website (don´t know how to do this remotely yet. Working on that. That´s why I found this question) before I deploy. Then I just sync directories in my computer (your /dist folder) and the path in the remote server.
This a piece of my Gruntfile.js with 2 examples defined in the grunt.initConfig()
'Backup' saves in a package (zip file) the current remote directory.
The second task called 'Oper' syncs your current build located on <%= yeoman.dist %>
msdeploy: {
backup: {
options: {
verb: "sync",
source: {
dirPath: '<%= deploy.Config.basePathOper %><%=deploy.Oper.Web %>,computerName=<%=deploy.Config.computerName %>,username=<%=deploy.Config.username %>,password=<%= deploy.Config.password %>'
},
dest: {
package: '<%= deploy.Config.basePathOper %>\\backups\\web_' + grunt.template.today("yyyy-mm-dd-HH-MM-ss") + '.zip,computerName=<%=deploy.Config.computerName %>,username=<%=deploy.Config.username %>,password=<%= deploy.Config.password %>'
}
}
},
Oper: {
options: {
verb: 'sync',
source: {
dirPath: process.cwd() + '\\<%= yeoman.dist %>'
},
dest: {
dirPath: '<%= deploy.Config.basePathOper %><%=deploy.Oper.Web %>,computerName=<%=deploy.Config.computerName %>,username=<%=deploy.Config.username %>,password=<%= deploy.Config.password %>'
}
}
}
The task I created looks something like this
grunt.registerTask('deploy', function (target) {
if (target === 'Oper') {
grunt.task.run([
'msdeploy:backup',
'msdeploy:Oper'
]);
}
});
Don´t forget to load the plugin:
grunt.loadNpmTasks('grunt-msdeploy');