Skip to content
arrow-up-circle

GitHub Action

ssh2-to-remote-action

v1.0.17 Latest version

ssh2-to-remote-action

arrow-up-circle

ssh2-to-remote-action

An action to upload a local directory to a remote server via SSH2 SFTP

Installation

Copy and paste the following snippet into your .yml file.

              

- name: ssh2-to-remote-action

uses: 2ue/[email protected]

Learn more about this action in 2ue/ssh2-to-remote-action

Choose a version

SSH2 SFTP Upload Action

A GitHub Action for uploading a local directory to a remote server via the SSH2 SFTP protocol.

You should store sensitive information such as host addresses, ports, usernames, and passwords as GitHub repository secrets and reference those secrets in your workflow for security.

English Doc 中文文档

Usage

To use this Action, you need to create a YAML file in the .github/workflows directory of your GitHub repository, such as deploy.yml, and add the following content:

jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Upload directory to SFTP server
        uses: your-username/ssh2-sftp-upload-action@v1
        with:
          host: ${{ secrets.HOST }}
          port: ${{ secrets.PORT }}
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}
          local_dir: './public'
          remote_base_dir: '/home/username/web'
          remote_bak_path: '/home/username/backup'

Make sure to replace ${{ secrets.HOST }}, ${{ secrets.PORT }}, ${{ secrets.USERNAME }}, and ${{ secrets.PASSWORD }} with the actual connection information of your SFTP server, which should be stored as repository secrets.

Input Parameters
  • host: Required - The remote host address.
  • port: Required - The port of the remote host.
  • username: Required - The username for authentication.
  • password: Required - The password for authentication.
  • local_dir: Required - The local directory path to upload.
  • remote_base_dir: Required - The base directory path on the remote server.
  • remote_bak_path: Optional - The backup directory path on the remote server.