appleboy / scp-action

GitHub Action that copy files and artifacts via SSH.
https://github.com/marketplace/actions/scp-command-to-transfer-files
MIT License
1.25k stars 135 forks source link

tar: empty archive exit status 1 #150

Open hw9402 opened 1 year ago

hw9402 commented 1 year ago

Hello! I need help about this error

tar all files into /tmp/3708965802/TApWAslSeb.tar
tar -cf /tmp/3708965802/TApWAslSeb.tar
tar: empty archive
exit status 1

when trying to upload react app build directory to my server with this workflow:

jobs:
  build:
    runs-on: ubuntu-latest

    env:
      CI: false

    steps:
      - uses: actions/checkout@v3

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 21.0.0

      - name: Install yarn
        run: npm install -g yarn

      - name: Install Dependencies
        run: yarn install --immutable --immutable-cache --check-cache

      - name: Build React App
        run: yarn run build

      - name: Check current directory
        run: | 
          ls -a build/
          echo "Current Directory: $(pwd)"

  deploy:
    needs: build
    runs-on: ubuntu-latest

    steps:
      - name: Deploy React App
        uses: appleboy/scp-action@v0.1.3
        with:
          host: ${{ secrets.SERVER_HOST }}
          username: ${{ secrets.SERVER_USERNAME }}
          password: ${{ secrets.SERVER_PASSWORD }}
          source: app/build/
          target: /home/${{ secrets.SERVER_USERNAME }}/project/nodam-nodam/
          rm: true
          debug: true

Also I verified that source directory(app/build/) exists by step Check current directory:

Run ls -a build/
  ls -a build/
  echo "Current Directory: $(pwd)"
  shell: /usr/bin/bash -e {0}
  env:
    CI: false
.
..
asset-manifest.json
assets
favicon.ico
index.html
logo19[2](https://github.com/ThisIsComedy/nodam-nodam_frontend/actions/runs/6905446166/job/18806315947#step:7:2).png
logo[5](https://github.com/ThisIsComedy/nodam-nodam_frontend/actions/runs/6905446166/job/18806315947#step:7:5)[12](https://github.com/ThisIsComedy/nodam-nodam_frontend/actions/runs/6905446166/job/18806315947#step:7:13).png
manifest.json
robots.txt
static
Current Directory: /home/runner/work/nodam-nodam_frontend/nodam-nodam_frontend

I have already searched for similar problems and solutions, but I can't solved it. How can I solve this problem?

kgoderis commented 1 year ago

+1

JordyEGNL commented 11 months ago

I had the same issue. Remove the slash at the begin for the source. source: "app/build"

Fearix commented 9 months ago

Hi, I solved this by combining the two jobs build and deploy to build_and_deploy, since a new job uses a new Ubuntu machine from GitHub that does not have the previously built files. So mine looks like this:

jobs:
  build_and_deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - uses: subosito/flutter-action@v2
        with:
          channel: 'stable'
      - run: flutter pub get
      - run: flutter build web
      - name: Deploy to web server
        uses: appleboy/scp-action@master
        with:
          host: ${{ secrets.WEB_SERVER_HOST }}
          username: ${{ secrets.WEB_SERVER_USERNAME }}
          password: ${{ secrets.SSH_PASSWORD }}
          source: "your_source_dir"
          target: "/var/www/html/public-flutter"
          debug: true
          rm: true
AmrHossam902 commented 6 months ago

what is the main reason behind this issue!!!! , I can't figure it out

- name: copying compose and env files
  uses: appleboy/scp-action@master
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USERNAME }}
          key: ${{ secrets.SSH_KEY }}
          port: ${{ secrets.SSH_PORT }}
          overwrite: true
          source: "./compose.yaml"
          target: "/home/ec2-user/uni-app/"
AmrHossam902 commented 6 months ago

I just figured out what is the reason, I forgot to checkout the repo. before doing this step, so make sure that the file itself exists and you have access to it, that's one of the reasons behind this error