Skip to content

recipes/rsync

View source on GitHub

typescript
import '@catapultjs/deploy/recipes/rsync'

Tasks

TaskInsertedDescription
deploy:update_codeOverrides the built-in task and syncs a local directory into releases/<release>/ via rsync

Configuration

KeyTypeDefaultDescription
rsync_source_pathstring./Local source directory. A trailing slash is added automatically so only the directory contents are transferred
source_pathstringFallback source directory if rsync_source_path is not set
rsync_excludesstring[][]Patterns passed to --exclude

The recipe always syncs to the new release directory and always uses --delete.

Windows

This recipe requires an rsync binary on the PATH. Native Windows (built-in OpenSSH) has no rsync, so run Catapult from WSL, Git Bash or MSYS2 when using this recipe. Recipes that rely only on ssh/scp work on native Windows once connection multiplexing is disabled (auto-detected off on Windows, see the multiplexing host option).

Build locally, then sync only generated artifacts:

typescript
import { defineConfig, set } from '@catapultjs/deploy'
import '@catapultjs/deploy/recipes/rsync'

set('rsync_source_path', './dist')
set('rsync_excludes', ['.env'])

export default defineConfig({
  hosts: [
    {
      name: 'production',
      ssh: 'deploy@example.com',
      deployPath: '/home/deploy/myapp',
    },
  ],
})

Or reuse the generic source_path key:

typescript
import { defineConfig, set } from '@catapultjs/deploy'
import '@catapultjs/deploy/recipes/rsync'

set('source_path', './build')

export default defineConfig({
  hosts: [
    {
      name: 'production',
      ssh: 'deploy@example.com',
      deployPath: '/home/deploy/myapp',
    },
  ],
})