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.15k stars 134 forks source link

tar: empty archive downloading file from server #78

Open DanielGilB opened 2 years ago

DanielGilB commented 2 years ago

Hey guys! Im trying to download a file from my server but i cant...

      - name: Download sql
        uses: appleboy/scp-action@master
        with:
          host: myhost
          username: myusername
          password: ${{ secrets.SSH_PASSWORD }}
          source: ${{ steps.date.outputs.date }}.sql
          target: backup

The error:

/usr/bin/docker run --name bcf09fe576e7914704faea5050a1000ca2d48_5c392f --label 2bcf09 --workdir /github/workspace --rm -e INPUT_HOST -e INPUT_USERNAME -e INPUT_PASSWORD -e INPUT_SOURCE -e INPUT_TARGET -e INPUT_PORT -e INPUT_TIMEOUT -e INPUT_COMMAND_TIMEOUT -e INPUT_KEY -e INPUT_KEY_PATH -e INPUT_PASSPHRASE -e INPUT_FINGERPRINT -e INPUT_USE_INSECURE_CIPHER -e INPUT_RM -e INPUT_DEBUG -e INPUT_STRIP_COMPONENTS -e INPUT_OVERWRITE -e INPUT_TAR_TMP_PATH -e INPUT_PROXY_HOST -e INPUT_PROXY_PORT -e INPUT_PROXY_USERNAME -e INPUT_PROXY_PASSWORD -e INPUT_PROXY_PASSPHRASE -e INPUT_PROXY_TIMEOUT -e INPUT_PROXY_KEY -e INPUT_PROXY_KEY_PATH -e INPUT_PROXY_FINGERPRINT -e INPUT_PROXY_USE_INSECURE_CIPHER -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/flashme-laravel/flashme-laravel":"/github/workspace" 2bcf09:fe576e7914704faea5050a1000ca2d48
tar all files into /tmp/307745993/azrwYDEkBp.tar
tar: empty archive
exit status 1`

I have checked from local to spc to the server and i downloaded the file with no problems.

Any idea with that? I have been reading some related issue but i didnt find a solution. Thanks in advance!

DanielGilB commented 2 years ago

I think I misunderstood the purpose of the action. Someone confirm if its possible to download files from the server. If its, source should be the server path and target the artifact ?

pg commented 2 years ago

The purpose of this action is to SCP files from your repository to a remote server. Does that make sense and answer your question?

DanielGilB commented 2 years ago

Yes, thanks you very much 😄

aledesigncouk commented 2 years ago

I had the same issue, and solved following this solution: Stack Overflow

adding this bit before the scp-action:

  - name: Run a multi-line script
    run: |
      mkdir ../build
      cp -TR . ../build
      tar -cvf deploy.tar ../build/
samalapsy commented 1 year ago

I just tried this on my end.. I got a successful build but the files weren't deploy.

- name: Run a multi-line script
      run: |
        mkdir ../build
        cp -TR . ../build
        tar -cvf deploy.tar ../build/

 - name: Copy file via sftp
      uses: appleboy/scp-action@master
      with:
        host: ${{ secrets.SSH_HOST }}
        username: ${{ secrets.SSH_USER}}
        overwrite: true
        password: ${{secrets.SSH_PASSWORD }}
        source: "deploy.tar"
        target: "/var/www/test/"

scp file to server.
create folder /var/www/test/
untar file RmlADCCQSQ.tar
remove file RmlADCCQSQ.tar
===================================================
✅ Successfully executed transfer data to all host
===================================================```

Please am I missing anything?
appleboy commented 1 year ago

please run ls -al command for debugging and post the result here.

run: ls -al .
Rico4338 commented 1 year ago

please run ls -al command for debugging and post the result here.

run: ls -al .

This made me realize that my path setting was wrong, thanks

mike-a commented 11 months ago

Same problems as above: tar: empty archive... exit status 1

Folder list using ls...

Run ls -al .
  ls -al .
  shell: /usr/bin/bash -e {0}
total 8
drwxr-xr-x 2 runner docker 4096 Jul 24 19:45 .
drwxr-xr-x 3 runner docker 4096 Jul 24 19:45 

My GH repo source is at test.txt or /localtestfolder/test.txt...

image

Destination folder as stated in extract MWE below. I've tried a variety of source and destination folder options, with and without quote wrapping. Please advise where I'm going wrong. TIA.

Jobbie-six:
    name: Server configurations
    runs-on: ubuntu-latest
    needs: [jobbie_one]
    steps:
      - name: List folders
        run: ls -al .

      - name: Transfer server configs to server
        uses: appleboy/scp-action@v0.1.4    # Sister action scp, not ssh:  See https://github.com/appleboy/scp-action
        with:
          username: ${{ secrets.USERNAME }}
          host: ${{ secrets.HOST }}
          key: ${{ secrets.SSHDVPT }}
          passphrase: ${{ secrets.PASSPHRASE }}
          port: 22
          debug: true
          rm: true  # Wipe server folder
          source: "/localtestfolder/test.txt"
          target: "/testfolder/"
          strip_components: 1
mike-a commented 11 months ago

Nothing after two weeks. The weakness of GH Actions.

mkarmona commented 8 months ago

having the same problem on my side. It says

tar all files into /tmp/NRFkvozvyg.tar.gz
$ tar -zcf /tmp/NRFkvozvyg.tar.gz
tar: empty archive
exit status 1

having the configuration

with:
    host: ......
    username: ***
    password: ***
    port: 22
    timeout: 180s
    source: /github/workspace/target/scala-2.12/zzzzzz_2.12.jar
    overwrite: true
    debug: true
    target: /projects/....../
    command_timeout: 10m
    use_insecure_cipher: false
    rm: false
    strip_components: 0
    tar_dereference: false
    tar_exec: tar
    proxy_port: 22
    proxy_timeout: 30s
    proxy_use_insecure_cipher: false
  env:
    SDKMAN_HOME: /root/.sdkman
    SCALA_MAJOR_VERSION: 2.12
    SCALA_VERSION: 2.12.15
    SBT_VERSION: 1.5.8
    JAVA_HOME: ....

is it related to the temporal target folder place or permissions? I will check this but it could be nice having a more detailed debug output