Coder Social home page Coder Social logo

lftp-mirror-action's Introduction

lftp-mirror-action

πŸš€ GitHub action to mirror files via SFTP.

Table of Contents

Usage

name: Deploy via SFTP
on:
  push:
    branches:
      - main
jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    if: github.event_name == 'push'
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Deploy files via SFTP
        uses: pressidium/lftp-mirror-action@v1
        with:
          # SFTP credentials
          host: ${{ secrets.SFTP_HOST }}
          port: ${{ secrets.SFTP_PORT }}
          user: ${{ secrets.SFTP_USER }}
          pass: ${{ secrets.SFTP_PASS }}
          # lftp settings
          onlyNewer: true
          settings: 'sftp:auto-confirm=yes'
          # Mirror command options
          localDir: '.'
          remoteDir: '/var/www/html/example.com/public'
          reverse: true
          ignoreFile: '.lftp_ignore'
          options: '--verbose'

Inputs

Parameter Description Required Default
host The hostname of the SFTP server Yes N/A
port The port of the SFTP server No '22'
user The username to use for authentication Yes N/A
pass The password to use for authentication Yes N/A
forceSSL Refuse to send password in clear when server does not support SSL No 'true'
verifyCertificate Verify server’s certificate to be signed by a known Certificate Authority No 'true'
fingerprint Key fingerprint of the host we want to connect to No ''
onlyNewer Only transfer files that are newer than the ones on the remote server No 'true'
restoreMTime Restore the modification time of the files No 'true'
parallel Number of parallel transfers No '1'
settings Any additional lftp settings to configure No ''
localDir The local directory to copy from (assuming reverse is set to true) No '.'
remoteDir The remote directory to copy to (assuming reverse is set to true) No '/var/www/html/'
reverse Whether to copy from the remote to the local or the other way around No 'true'
ignoreFile The name of the file to use as the ignore list No '.lftp_ignore'
options Any additional mirror command options to configure No ''

Fingerprint

Omitting the fingerprint input, defaults to accepting any fingerprint (i.e. automatically adding the host/port to the known_hosts file)

Restoring modification times

⚠️ Read this section if lftp-mirror-action uploads all files every time it runs.

Git does not preserve the original modification time of committed files. When repositories are cloned, branches are checked out, etc., the modification time of the files is updated to the current time. This means that the modification time of the files on the GitHub runner will always be newer than the files on the SFTP server, which will result in the mirror command always uploading all files (since lftp determines whether a file has changed based on its file size and timestamp).

To prevent this, if onlyNewer is set to true, we restore the modification time of the files based on the date of the most recent commit that modified them. You can disable this behavior by setting restoreMTime to false (useful if you've already run an action like git-restore-mtime-action in your GitHub Actions workflow).

If you're using actions/checkout β‰₯ v2 you must set fetch-depth to 0 in order to fetch the entire Git history.

Bugs & Features

If you've spotted any bugs, or would like to request additional features from this GitHub Action, please open an issue.

License

The MIT License, check the LICENSE file.

lftp-mirror-action's People

Contributors

leek avatar over-engineer 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.