githubsftpgithub-actions

How to SFTP with Github Actions?


I want to use Github actions to transfer files to a remote server via SFTP (only option for this server) when I push up to Github.

I am using this Action https://github.com/marketplace/actions/ftp-deploy

I have created a file in my repo in .github/workflows/main.yml and I have added:

on: push
name: Publish Website
jobs:
  FTP-Deploy-Action:
    name: FTP-Deploy-Action
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2.1.0
      with:
        fetch-depth: 2
    - name: FTP-Deploy-Action
      uses: SamKirkland/FTP-Deploy-Action@3.1.1
      with:
        ftp-server: ${{ secrets.FTP_SERVER }}
        ftp-username: ${{ secrets.FTP_USERNAME }}
        ftp-password: ${{ secrets.FTP_PASSWORD }}

I have created a Secret for this repo which contains the following:

FTP_SERVER: sftp.server.com, FTP_USERNAME: user, FTP_PASSWORD: password

I can see the action running in Github but it errors out on the FTP-Deploy-Action task.

##[error]Input required and not supplied: ftp-server

This is in secrets and does work with Filezilla.

Would anyone know if I've set this up wrongly?


Solution

  • I was able to get it working on my own repo. I think the issue may be possibly on how your secrets were setup. That error usually shows when required parameters of a github action were not provided so curious if the keys are different or whether they were saved as empty. I would delete FTP_SERVER secret and create it again to be sure.

    Workflow Success Run

    Workflow Code

      - name: FTP-Deploy-Action
        uses: SamKirkland/FTP-Deploy-Action@3.1.1
        with:
          ftp-server: ${{ secrets.FTP_SERVER }}
          ftp-username: ${{ secrets.FTP_USERNAME }}
          ftp-password: ${{ secrets.FTP_PASSWORD }}
          local-dir: toupload
    

    UPDATE: Added example per comment left below,

    Example secret creation for reference. Basically create a secret per entry rather than comma separated grouped secret

    enter image description here

    Source: https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets