Travis

Custom Deployment

This page documents deployments using dpl v1 which is currently the legacy version. The dpl v2 is released, and we recommend useig it. Please see our blog post for details. dpl v2 documentation can be found here.

You can deploy to your own server the way you would deploy from your local machine by adding a custom after_success step.

You may choose the Script provider instead, as it provides conditional deployment.

SFTP #

env:
  global:
  - 'SFTP_USER=[user]'
  - 'SFTP_PASSWORD=[password]'
  - 'SFTP_KEY=[base64-encoded-rsa-key]'
after_success:
- echo "${SFTP_KEY}" | base64 --decode >/tmp/sftp_rsa
- curl --ftp-create-dirs
       -T filename
       --key /tmp/sftp_rsa
       sftp://${SFTP_USER}:${SFTP_PASSWORD}@example.com/directory/filename

The env variables SFTP_USER and SFTP_PASSWORD can also be encrypted.

See curl(1) for more details on how to use cURL as an SFTP client.

Git #

This should also work with services you can deploy to via git.

after_success:
  - eval "$(ssh-agent -s)" #start the ssh agent
  - chmod 600 .travis/deploy_key.pem # this key should have push access
  - ssh-add .travis/deploy_key.pem
  - git remote add deploy DEPLOY_REPO_URI_GOES_HERE
  - git push deploy

See “How can I encrypt files that include sensitive data?” if you don’t want to commit the private key to your repository unencrypted.