name: Push to SFTP on: workflow_dispatch: # push: # branches: # - main # Optional: Run automatically on pushes to the main branch jobs: deploy-to-sftp: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v7 - name: Install lftp and ssh run: sudo apt-get update && sudo apt-get install -y lftp openssh-client - name: Set up SSH Private Key env: # Binds the secret to a secure environment variable SSH_PRIVATE_KEY: ${{ secrets.SSH }} run: | mkdir -p ~/.ssh # Uses the environment variable, so the raw key is never printed in the execution log echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa - name: Push files via SFTP with progress run: | # The mirror command below uses the -R (reverse) flag # to push from local './' to remote './' # Connection is made using 'open' inside the execution block to enforce SSH key usage lftp -e "set sftp:connect-program 'ssh -a -x -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -o BatchMode=yes -o PasswordAuthentication=no'; \ set sftp:auto-confirm yes; \ set net:max-retries 5; \ set net:timeout 30; \ set cmd:fail-exit yes; \ open -u ${{ secrets.SSH_USER }}, sftp://sftp.node4.immortal.host:2022; \ mirror -R --verbose --parallel=4 ./ ./; \ quit"