Skip to content

Commit

Permalink
docs(recipes): update rsync-deploy (#775)
Browse files Browse the repository at this point in the history
see: #742

Signed-off-by: Antoine Leblanc <[email protected]>
  • Loading branch information
antleblanc authored Apr 19, 2020
1 parent 8a79e54 commit 5ea724d
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions docs/recipes/rsync-deploy.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rsync Deploying

This is an easy way publish your site with rsynch to serve the generated static files.
This is an easy way publish your site with [rsync](https://rsync.samba.org/) to serve the generated static files.

## Steps

Expand All @@ -13,46 +13,47 @@ $ npm install --save-dev gulp-rsync
```

### 2. Create a `rsync config` file
Add a file to project root `rsync.json`.

Add a file to project root `rsync.json`.

```
```json
{
"hostname": "hostname or ip",
"username": "username",
"destination": "folder"
"hostname": "hostname or ip",
"username": "username",
"destination": "folder"
}
```

for example
```
For example:
```json
{
"hostname": "example.com",
"username": "user1",
"destination": "/home/httpd/website"
"hostname": "example.com",
"username": "user1",
"destination": "/home/httpd/website"
}
```



### 3. Create a `deploy` task

Add this task to your `gulpfile.js`. It will run `build` task before deploying:

```js
gulp.task('deploy', ['build'], () => {

const rsyncConfig = require('./rsync.json');

return gulp.src('dist/**')
.pipe($.rsync({
root: 'dist',
hostname: rsyncConfig.hostname,
username: rsyncConfig.username,
destination: rsyncConfig.destination,
progress: true
}));
function rsync() {
const rsyncConfig = require('./rsync.json');

return src('dist/**')
.pipe($.rsync({
root: 'dist',
hostname: rsyncConfig.hostname,
username: rsyncConfig.username,
destination: rsyncConfig.destination,
progress: true
}));
});

const deploy = series(build, rsync);

exports.deploy = deploy;
```

### 4. Deploy
Expand All @@ -63,12 +64,10 @@ Run the following command to deploy:
$ gulp deploy
```

### Tip
### Tips

It is highly recommended to enable [asset revisioning](asset-revisioning.md).

### Tip

You can add `rsync.json` file to `.gitignore` to protect your connection data.
```
/rsync.json
Expand Down

0 comments on commit 5ea724d

Please sign in to comment.