Skip to content

dj-256/github-deploy

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

github-deploy

Github Action providing simple scp feature

Examples

Copy a single file

- name: Copy single file
  uses: dj-256/github-deploy@v1
  with:
    local: main.py
    remote: /home/user/example
    host: ${{ secrets.HOST }}
    port: ${{ secrets.PORT }}
    username: ${{ secrets.USERNAME }}
    password: ${{ secrets.PASSWORD }}

Copy a directory recursively

- name: Copy entire directory
  uses: dj-256/github-deploy@v1
  with:
    local: ./dist
    remote: /var/www/app
    host: ${{ secrets.HOST }}
    username: ${{ secrets.SSH_USER }}
    password: ${{ secrets.PASSWORD }}

Copy a directory excluding some files

- name: Excluding JS files
  uses: dj-256/github-deploy@v1
  with:
      local: dist
      remote: /home/example/
      host: ${{ secrets.HOST }}
      username: ${{ secrets.SSH_USER }}
      password: ${{ secrets.PASSWORD }}
      exclude: '*.js'

Copy a directory excluding a subdirectory

- name: Copy exluding subdirectory
  uses: dj-256/github-deploy@v1
  with:
      local: ./
      remote: /var/www/dir
      host: ${{ secrets.HOST }}
      username: ${{ secrets.SSH_USER }}
      password: ${{ secrets.PASSWORD }}
      port: ${{ secrets.SSH_PORT }}
      exclude: 'out'

Options

  • local - string - Path to the local file or directory you want to copy, relative to repository root. required

  • remote - string - Path to the remote directory to copy the contents to, absolute. required

  • host - string - Hostname or IP address of the server. Default: 'localhost'

  • port - integer - Port number of the server. Default: 22

  • username - string - Username for authentication. Default: (none)

  • password - string - Password for password-based user authentication. Default: (none)

  • passphrase - string - For an encrypted private key, this is the passphrase used to decrypt it. Default: (none)

  • rmRemote - boolean - Clean directory before uploading. Default: false

  • exclude - string - Paths excluded from the copy, relative to remote path. You can specify a single file or directory or else, use a glob.

Development

This has been strongly inspired by garygrossgarten's github-action-scp it uses node-scp and glob