SamKirkland / FTP-Deploy-Action

Deploys a GitHub project to a FTP server using GitHub actions
MIT License
3.89k stars 375 forks source link

Incomplete upload (FTPError) resulting in broken production site + action does not fail #152

Open Saloh opened 3 years ago

Saloh commented 3 years ago

What do I do? On push or pull request onto the master branch a job is building the current repository. If the build job succeeds a second job is triggered which uses FTP-Deploy-Action to upload the built ./dist/ folder to my webserver into the ./html/ directory.

Bug Description The upload reliably fails as seen in the action log. It throws three FTPErrors and aborts connection (see example vsftp log below) to the ftp server. Although the upload is incomplete and resulting in a broken deployed build the action doesn't fail (probably related to #150). This means you wont notice the error until you try to open the broken website and dive into those logs posted below.

My Action Config


on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build:
    name: build
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [14.15.1]

    defaults:
      run:
        working-directory: ./

    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm install
      - run: npm run build --if-present
      - run: npm test --if-present
        env:
          CI: true

  web-deploy:
    name: web-deploy
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Get latest code
        uses: actions/checkout@v2.3.2

      - name: Use Node.js 14.15.1
        uses: actions/setup-node@v2-beta
        with:
          node-version: '14.15.1'

      - name: Build Project
        run: |
          npm install
          npm run build

      - name: Sync files
        uses: SamKirkland/FTP-Deploy-Action@4.0.0
        with:
          server: domain_name.com
          username: ${{ secrets.FTP_USER }}
          password: ${{ secrets.FTP_PASSWORD }}
          protocol: ftps
          security: strict
          local-dir: ./dist/
          server-dir: ./html/
          dry-run: false
          log-level: verbose

My Action Log

   # Paste Log here
   # you may want enable verbose logging with   log-level: verbose
----------------------------------------------------------------
πŸš€ Thanks for using ftp-deploy. Let's deploy some stuff!   
----------------------------------------------------------------
If you found this project helpful, please support it
by giving it a ⭐ on Github --> https://github.com/SamKirkland/FTP-Deploy-Action
or add a badge 🏷️ to your projects readme --> https://github.com/SamKirkland/FTP-Deploy-Action#badge
Creating local state at ./dist/.ftp-deploy-sync-state.json
Local state created
Connected to SERVER_IP:21 (No encryption)
< 220 (vsFTPd 3.0.3)

> AUTH TLS
< 234 Proceed with negotiation.

Control socket is using: TLSv1.3
Login security: TLSv1.3
> USER ***
< 331 Please specify the password.

> PASS ###
< 230 Login successful.

> TYPE I
< 200 Switching to Binary mode.

> STRU F
< 200 Structure set to F.

> OPTS UTF8 ON
< 200 Always in UTF8 mode.

> OPTS MLST type;size;modify;unique;unix.mode;unix.owner;unix.group;unix.ownername;unix.groupname;
< 501 Option not understood.

> PBSZ 0
< 200 PBSZ set to 0.

> PROT P
< 200 PROT now Private.

  changing dir to ./html/
> MKD .
< 550 Create directory operation failed.

> CWD .
< 250 Directory successfully changed.

> MKD html
< 550 Create directory operation failed.

> CWD html
< 250 Directory successfully changed.

  dir changed
Trying to find optimal transfer strategy...
> EPSV
< 229 Entering Extended Passive Mode (|||43408|)

Optimal transfer strategy found.
> RETR .ftp-deploy-sync-state.json
< 550 Failed to open file.

----------------------------------------------------------------
No file exists on the server "./html/.ftp-deploy-sync-state.json" - this much be your first publish! πŸŽ‰
The first publish will take a while... but once the initial sync is done only differences are published!
If you get this message and its NOT your first publish, something is wrong.
----------------------------------------------------------------
Local Files:    15
Server Files:   15
----------------------------------------------------------------
Calculating differences between client & server
----------------------------------------------------------------
πŸ“ Create: css
βž• Upload: css/app.530b0f43.css
βž• Upload: css/chunk-vendors.94bc0478.css
βž• Upload: favicon.ico
πŸ“ Create: img
βž• Upload: img/de.69ccebc7.svg
βž• Upload: img/gb.c4cd6642.svg
βž• Upload: img/nk.36cd8266.jpg
βž• Upload: img/Ufer_StVO_1992.svg.36be322b.png
βž• Upload: index.html
πŸ“ Create: js
βž• Upload: js/app.a4068a06.js
βž• Upload: js/app.a4068a06.js.map
βž• Upload: js/chunk-vendors.61fa426d.js
βž• Upload: js/chunk-vendors.61fa426d.js.map
----------------------------------------------------------------
Making changes to 15 files to sync server state
Uploading: 4.33 MB -- Deleting: 0 B -- Replacing: 0 B
----------------------------------------------------------------
creating folder "css/"
  changing dir to css
> MKD css
< 257 "/html/css" created

> CWD css
< 250 Directory successfully changed.

  dir changed
> CDUP
< 250 Directory successfully changed.

  completed
creating folder "img/"
  changing dir to img
> MKD img
< 257 "/html/img" created

> CWD img
< 250 Directory successfully changed.

  dir changed
> CDUP
< 250 Directory successfully changed.

  completed
creating folder "js/"
  changing dir to js
> MKD js
< 257 "/html/js" created

> CWD js
< 250 Directory successfully changed.

  dir changed
> CDUP
< 250 Directory successfully changed.

  completed
uploading "css/app.530b0f43.css"
> EPSV
< 229 Entering Extended Passive Mode (|||47203|)

> STOR css/app.530b0f43.css
< 150 Ok to send data.

Uploading to SERVER_IP:47203 (TLSv1.3)
upload progress for "css/app.530b0f43.css". Progress: 0 bytes of 0 bytes
upload progress for "css/app.530b0f43.css". Progress: 2195 bytes of 2195 bytes
< 226 Transfer complete.

  file uploaded
uploading "css/chunk-vendors.94bc0478.css"
> EPSV
< 229 Entering Extended Passive Mode (|||43239|)

> STOR css/chunk-vendors.94bc0478.css
< 150 Ok to send data.

Uploading to SERVER_IP:43239 (TLSv1.3)
upload progress for "css/chunk-vendors.94bc0478.css". Progress: 0 bytes of 2195 bytes
upload progress for "css/chunk-vendors.94bc0478.css". Progress: 215241 bytes of 217436 bytes
< 226 Transfer complete.

  file uploaded
uploading "favicon.ico"
> EPSV
< 229 Entering Extended Passive Mode (|||47418|)

> STOR favicon.ico
< 150 Ok to send data.

Uploading to SERVER_IP:47418 (TLSv1.3)
upload progress for "favicon.ico". Progress: 0 bytes of 217436 bytes
upload progress for "favicon.ico". Progress: 4286 bytes of 221722 bytes
< 226 Transfer complete.

  file uploaded
uploading "img/de.69ccebc7.svg"
> EPSV
< 229 Entering Extended Passive Mode (|||47173|)

> STOR img/de.69ccebc7.svg
< 150 Ok to send data.

Uploading to SERVER_IP:47173 (TLSv1.3)
upload progress for "img/de.69ccebc7.svg". Progress: 0 bytes of 221722 bytes
upload progress for "img/de.69ccebc7.svg". Progress: 308 bytes of 222030 bytes
< 226 Transfer complete.

  file uploaded
uploading "img/gb.c4cd6642.svg"
> EPSV
< 229 Entering Extended Passive Mode (|||42582|)

> STOR img/gb.c4cd6642.svg
< 150 Ok to send data.

Uploading to SERVER_IP:42582 (TLSv1.3)
upload progress for "img/gb.c4cd6642.svg". Progress: 0 bytes of 222030 bytes
upload progress for "img/gb.c4cd6642.svg". Progress: 495 bytes of 222525 bytes
< 226 Transfer complete.

  file uploaded
uploading "img/nk.36cd8266.jpg"
> EPSV
< 229 Entering Extended Passive Mode (|||41603|)

> STOR img/nk.36cd8266.jpg
< 150 Ok to send data.

Uploading to SERVER_IP:41603 (TLSv1.3)
upload progress for "img/nk.36cd8266.jpg". Progress: 0 bytes of 222525 bytes
upload progress for "img/nk.36cd8266.jpg". Progress: 5575 bytes of 228100 bytes
< 226 Transfer complete.

  file uploaded
uploading "img/Ufer_StVO_1992.svg.36be322b.png"
> EPSV
< 229 Entering Extended Passive Mode (|||45308|)

> STOR img/Ufer_StVO_1992.svg.36be322b.png
< 150 Ok to send data.

Uploading to SERVER_IP:45308 (TLSv1.3)
upload progress for "img/Ufer_StVO_1992.svg.36be322b.png". Progress: 0 bytes of 228100 bytes
upload progress for "img/Ufer_StVO_1992.svg.36be322b.png". Progress: 236519 bytes of 464619 bytes
< 226 Transfer complete.

  file uploaded
uploading "index.html"
> EPSV
< 229 Entering Extended Passive Mode (|||46869|)

> STOR index.html
< 150 Ok to send data.

Uploading to SERVER_IP:46869 (TLSv1.3)
upload progress for "index.html". Progress: 0 bytes of 464619 bytes
upload progress for "index.html". Progress: 864 bytes of 465483 bytes
< 226 Transfer complete.

  file uploaded
uploading "js/app.a4068a06.js"
> EPSV
< 229 Entering Extended Passive Mode (|||41544|)

> STOR js/app.a4068a06.js
< 150 Ok to send data.

Uploading to SERVER_IP:41544 (TLSv1.3)
upload progress for "js/app.a4068a06.js". Progress: 0 bytes of 465483 bytes
upload progress for "js/app.a4068a06.js". Progress: 31280 bytes of 496763 bytes
< 426 Failure reading network stream.

400 level error from server when performing action - retrying...
FTPError: 426 Failure reading network stream.
    at FTPContext._onControlSocketData (/home/runner/work/_actions/SamKirkland/FTP-Deploy-Action/4.0.0/dist/index.js:3759:39)
    at TLSSocket.<anonymous> (/home/runner/work/_actions/SamKirkland/FTP-Deploy-Action/4.0.0/dist/index.js:3600:44)
    at TLSSocket.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:286:13)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:182:23) {
  name: 'FTPError',
  code: 426
}
Connection closed. This library does not currently handle reconnects
FTPError: 426 Failure reading network stream.
    at FTPContext._onControlSocketData (/home/runner/work/_actions/SamKirkland/FTP-Deploy-Action/4.0.0/dist/index.js:3759:39)
    at TLSSocket.<anonymous> (/home/runner/work/_actions/SamKirkland/FTP-Deploy-Action/4.0.0/dist/index.js:3600:44)
    at TLSSocket.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:286:13)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:182:23) {
  name: 'FTPError',
  code: 426
}
FTPError: 426 Failure reading network stream.
    at FTPContext._onControlSocketData (/home/runner/work/_actions/SamKirkland/FTP-Deploy-Action/4.0.0/dist/index.js:3759:39)
    at TLSSocket.<anonymous> (/home/runner/work/_actions/SamKirkland/FTP-Deploy-Action/4.0.0/dist/index.js:3600:44)
    at TLSSocket.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:286:13)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:182:23) {
  name: 'FTPError',
  code: 426
}
----------------------------------------------------------------
Time spent hashing:               32 milliseconds
Time spent connecting to server:  1.4 seconds
Time spent deploying:             6.7 seconds (644 kB/second)
  - changing dirs:                940 milliseconds
  - logging:                      69 milliseconds
----------------------------------------------------------------
Total time:                       8.8 seconds
----------------------------------------------------------------

vsftp log

Wed Dec 30 15:24:29 2020 [pid 8693] CONNECT: Client "GITHUB_ACTION_SERVER_IP"
Wed Dec 30 15:24:30 2020 [pid 8692] [FTP_USER] OK LOGIN: Client "GITHUB_ACTION_SERVER_IP"
Wed Dec 30 15:24:31 2020 [pid 8694] [FTP_USER] FAIL MKDIR: Client "GITHUB_ACTION_SERVER_IP", "/."
Wed Dec 30 15:24:31 2020 [pid 8694] [FTP_USER] FAIL MKDIR: Client "GITHUB_ACTION_SERVER_IP", "/html"
Wed Dec 30 15:24:32 2020 [pid 8694] [FTP_USER] FAIL DOWNLOAD: Client "GITHUB_ACTION_SERVER_IP", "/html/.ftp-deploy-sync-state.json", 0.00Kbyte/sec
Wed Dec 30 15:24:32 2020 [pid 8694] [FTP_USER] OK MKDIR: Client "GITHUB_ACTION_SERVER_IP", "/html/css"
Wed Dec 30 15:24:33 2020 [pid 8694] [FTP_USER] OK MKDIR: Client "GITHUB_ACTION_SERVER_IP", "/html/img"
Wed Dec 30 15:24:33 2020 [pid 8694] [FTP_USER] OK MKDIR: Client "GITHUB_ACTION_SERVER_IP", "/html/js"
Wed Dec 30 15:24:34 2020 [pid 8694] [FTP_USER] OK UPLOAD: Client "GITHUB_ACTION_SERVER_IP", "/html/css/app.530b0f43.css", 2195 bytes, 3.38Kbyte/sec
Wed Dec 30 15:24:36 2020 [pid 8694] [FTP_USER] OK UPLOAD: Client "GITHUB_ACTION_SERVER_IP", "/html/css/chunk-vendors.94bc0478.css", 215241 bytes, 276.43Kbyte/sec
Wed Dec 30 15:24:36 2020 [pid 8694] [FTP_USER] OK UPLOAD: Client "GITHUB_ACTION_SERVER_IP", "/html/favicon.ico", 4286 bytes, 11.01Kbyte/sec
Wed Dec 30 15:24:37 2020 [pid 8694] [FTP_USER] OK UPLOAD: Client "GITHUB_ACTION_SERVER_IP", "/html/img/de.69ccebc7.svg", 308 bytes, 0.79Kbyte/sec
Wed Dec 30 15:24:38 2020 [pid 8694] [FTP_USER] OK UPLOAD: Client "GITHUB_ACTION_SERVER_IP", "/html/img/gb.c4cd6642.svg", 495 bytes, 1.27Kbyte/sec
Wed Dec 30 15:24:39 2020 [pid 8694] [FTP_USER] OK UPLOAD: Client "GITHUB_ACTION_SERVER_IP", "/html/img/nk.36cd8266.jpg", 5575 bytes, 14.34Kbyte/sec
Wed Dec 30 15:24:40 2020 [pid 8694] [FTP_USER] OK UPLOAD: Client "GITHUB_ACTION_SERVER_IP", "/html/img/Ufer_StVO_1992.svg.36be322b.png", 236519 bytes, 260.59Kbyte/sec
Wed Dec 30 15:24:41 2020 [pid 8694] [FTP_USER] OK UPLOAD: Client "GITHUB_ACTION_SERVER_IP", "/html/index.html", 864 bytes, 2.22Kbyte/sec
Wed Dec 30 15:24:42 2020 [pid 8693] [FTP_USER] DEBUG: Client "GITHUB_ACTION_SERVER_IP", "DATA connection terminated without SSL shutdown. Buggy client! Integrity of upload cannot be asserted."
Wed Dec 30 15:24:42 2020 [pid 8694] [FTP_USER] FAIL UPLOAD: Client "GITHUB_ACTION_SERVER_IP", "/html/js/app.a4068a06.js", 16384 bytes, 31.50Kbyte/sec
Wed Dec 30 15:24:42 2020 [pid 8693] [FTP_USER] DEBUG: Client "GITHUB_ACTION_SERVER_IP", "Control connection terminated without SSL shutdown."
TimAnthonyAlexander commented 3 years ago

Any updates? Did you get it to work later on?

Saloh commented 3 years ago

No, sadly it didn't work. @TimAnthonyAlexander

TimAnthonyAlexander commented 3 years ago

No, sadly it didn't work. @TimAnthonyAlexander

I found a solution for myself, which was using a pre-push hook. There are great scripts that you can use as pre-push hooks that just upload the files via git-ftp, for example.

My script looks like this:

#!/bin/sh
git ftp push
exit 0

And I installed git-ftp and configured it to upload to my ftp server.

nicolascedilnik commented 3 years ago

Any update on this? I am also experiencing this, using vsftpd as well. This github action looks nice besides that…

mfsbo commented 3 years ago

Same here. Was able to see a folder creation failed on ftp action but the action was marked as successful in github workflow so reports came through as completed successful but ftp was missing some folders which were listed in details of the successful completed ftp task. Some other tasks show warnings and errors if something has failed. It would be good if this task also produced some annotations for warnings like "seems like first upload so sync file created for you at /path/to/sync_file.ext"