Search code examples
github-actionsscp

Deploying to server via GitHub Actions and appleboy/scp-action fails with Tar short read error


I'm setting up an Express.js website that uses e.js as its rendering engine. I've been using a successful deployment script that has worked for me on many Node related projects, however this will be the first time I am using it to deploy Express and its related files. Be this as it may, these files can include .js files, .png files, .ejs files, so on and so forth, however, when I attempt to deploy, all works well except appleboys' scp-action tool. The current setup deploys the files using checkout which succeeds, however, when it gets to the tarring step, it immediately fails and does not continue.

The deployment script

name: Deploy to Production
on:
  push:
    branches:
      - master
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3
      - name: Deploy Files to server
        uses: appleboy/[email protected]
        with:
          host: ${{ secrets.DEPLOY_IP }}
          username: ${{ secrets.DPLY_USER }}
          password: ${{ secrets.DPLY_PWD }}
          overwrite: false
          source: "/*"
          target: ${{ secrets.PROJECT_PATH }}
      - name: Update Server-Side Scripts
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.DEPLOY_IP }}
          username: ${{ secrets.DPLY_USER }}
          password: ${{ secrets.DPLY_PWD }}
          script: |
            cd ${{ secrets.MAIN_PROJECT_PATH }}
            npm install
            pm2 restart 1

The error that occurs when running ERROR DESCRIPTION

So I know that short read error means the file is corrupted, but I'm not sure why the file is suddenly corrupted, or how to prevent it. There are no corrupted files within the project. I have a feeling it is because the .ejs files are not exactly a real file type, but I am unsure how to do this otherwise.

Any help or other suggestions on how to do this would be great, thanks!


Solution

  • Issue was solved by correcting the source directory to ./* instead of /*

    credits to @Azeem