Deploying to FTP server in Github Actions does not work

2.1k views Asked by At

As the title says, deploying to FTP server isn't working for me from a Github Action. I've tried using a couple of actions to accomplish this (FTP-Deploy and ftp-action), but FTP-Deploy just kept running with sporadic

curl: (7) Failed to connect to ftpservername.com port 21: Connection timed out

messages and ftp-action kept running without any output. Note: The server is available, I connected and transferred some files using Filezilla without any issues.

After that I tried using lftp, this is the command I used on a local Ubuntu machine

lftp -c "open -u username,password ftpservername.com; mirror -R locfolder remote/remotefolder"

and the file transfer worked, but when used in a Github Action it produced this output:

---- Connecting to ftpservername.com (123.456.789.123) port 21

mkdir `remote/remotefolder' [Connecting...]

**** Socket error (Connection timed out) - reconnecting

---- Closing control socket

---- Connecting to ftpservername.com (123.456.789.123) port 21

I tried setting both ftp:ssl-allow and ssl:verify-certificate to false, but this did not produce any results. Also, I do not have access to the server, so I can't check the server logs.

This is the workflow file:

name: Test

on:
  push:
    branches: [master]
jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repo
      uses: actions/checkout@v2
  
    - name: Setup Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.x'

    - name: Install pip
      run: python -m pip install --upgrade pip

    - name: Install packages
      run: |
        sudo apt install lftp
        sudo apt install expect
  
    .
    .
    .
    - name: FTP Deploy
      run: |
        echo Starting...
        unbuffer lftp -c "debug; set ftp:ssl-allow false; set ssl:verify-certificate false; open -u username,${{ secrets.PASSWORD }} ftpservername.com; mirror -R -v locfolder remote/remotefolder"
        echo Done transferring files.

Any help is appreciated, thank you!

1

There are 1 answers

0
Dinac23 On BEST ANSWER

Found the issue, the hosting service was blocking the IP address (as it was an IP address outside of the country). After setting up a self-hosted runner and whitelisting the IP of the runner everything works fine.