Git Product home page Git Product logo

sftp-upload-action's Introduction

sftp-upload-action

this is a github action script for upload files to server via SFTP protocol.

Snyk Vulnerabilities for GitHub Repo release Depfu

Inputs

  host: 'example.com',                  # Required.
  port: 22,                             # Optional, Default to 22.
  username: 'user',                     # Required.
  password: 'password',                 # Optional.
  privateKey: '',                       # Optional, your private key(Raw content or key path).
  passphrase: '',                       # Optional.
  agent: '',                            # Optional, path to the ssh-agent socket.
  compress: false,                      # Optional, compress for ssh connection. Default to false.
  localDir: 'dist',                     # Required, Absolute or relative to cwd.
  remoteDir: '/path/to/dest'            # Required, Absolute path only.
  dryRun: false                         # Optional. Default to false.
  exclude: 'node_modules/,**/*.spec.ts' # Optional. exclude patterns (glob) like .gitignore, use ',' to split, Default to ''.
  forceUpload: false                    # Optional, Force uploading all files, Default to false(upload only newer files).
  removeExtraFilesOnServer: false       # Optional, Remove extra files on server. Default to false.

Example usage

Use password

- name: SFTP uploader
  uses: wangyucode/[email protected]
  with:
    host: 'wycode.cn'
    password: ${{ secrets.password }} 
    localDir: 'dist'
    remoteDir: '/data/nginx/www/wycode.cn/'

Use privateKey

- name: SFTP uploader
  uses: wangyucode/[email protected]
  with:
    host: 'wycode.cn'
    privateKey: ${{ secrets.key }} 
    localDir: 'dist'
    remoteDir: '/data/nginx/www/wycode.cn/'

Example for a complete github action file

name: Upload complete repo (e.g. website) to a SFTP destination

on: [push]

jobs:
  Upload-to-SFTP:
    runs-on: ubuntu-latest
    steps:
      - name: ๐Ÿšš Get latest code                     # Checkout the latest code
        uses: actions/checkout@v2

      - name: ๐Ÿ“‚ SFTP uploader                       # Upload to SFTP 
        uses: wangyucode/[email protected]
        with:
          host: ${{ secrets.HOST }}                  # Recommended to put the credentials in github secrets.
          username: ${{ secrets.USER }}
          password: ${{ secrets.PASSWORD }}
          compress: true                             # Compression
          forceUpload: true                          # Optional, Force uploading all files, Default to false(upload only newer files).
          localDir: '.'                              # Required, Absolute or relative to cwd.
          remoteDir: '/'                             # Required, Absolute path only.
          exclude: '.git*,.DS_Store'                 # Optional. exclude patterns (glob) like .gitignore, use ',' to split, Default to ''.
ยดยดยด
## Upload newer files

the action will check `modifyTime` and upload the newer files if `forceUpload` is false.
but you should restore the modified time before uploading.
here is an action that can change the modified time: https://github.com/marketplace/actions/git-restore-mtime

sftp-upload-action's People

Contributors

dependabot[bot] avatar ivodek avatar squaredp avatar wangyucode avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.