garygrossgarten / github-action-scp

⬆️ Copy a folder to a remote server using SSH
MIT License
189 stars 53 forks source link

Upload compressed files doesn't work #50

Open sact1909 opened 1 month ago

sact1909 commented 1 month ago

I'm trying to upload a .tar file, but when the action connects to the server it uploads the tar file with a dot in front of the name and don't remove the existing files just paste the tar file with a wrong name and delay a lot after that, just pass as it worked but not, is uploading the file with a wrong nade and never delete the existing files

Example Correct: "Contabo.tar" Action: ".Contabo.tar"

my yml file

name: Deploy to Contabo

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

env:
  NUGET_URL: "https://nuget.devexpress.com/api"

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - name: Ensure GitHub NuGet Source
      run: |
        dotnet nuget add source ${{ env.NUGET_URL }} \
        -n DevExpressFeed \
        -u DevExpress \
        -p ${{ secrets.DEVEXPRESS_NUGET_KEY }} \
        --store-password-in-clear-text
    - uses: actions/checkout@v4
    - name: Setup .NET
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: 8.0.x
    - name: Restore dependencies
      run: dotnet restore
    - name: Build
      run: dotnet build --no-restore
    - name: dotnet publish
      run: dotnet publish -c Release --no-restore -o ./publish 

    - name: Creating Artifact
      run: |
           mkdir ./Zipfiles
           cd publish
           tar cvf ../Contabo.tar *
           cd ..
           mv Contabo.tar ./Zipfiles 

    - name: Publishing Artifact
      uses: garygrossgarten/github-action-scp@release
      with:
        local: Zipfiles
        remote: C:\Projects\ContaboApp
        host: ${{ secrets.SERVER_IP }}
        username: ${{secrets.SSH_USER}}
        privateKey: ${{ secrets.PRIVATE_KEY }}
        passphrase: ${{ secrets.PASSPHRASE }}
        rmRemote: true
akema-trebla commented 1 month ago

Same here. Trying to upload a zip file but it just creates a .[filename].zip instead and this just started happening not too long ago.

Any workaround?

sact1909 commented 1 month ago

Same here. Trying to upload a zip file but it just creates a .[filename].zip instead and this just started happening not too long ago.

Any workaround?

Hey man @akema-trebla , till now I don't really know what the problem is, but I'm guessing the problem comes from the github runners, because this action was working fine till now and I had to clone the repo and tested on my machine (I use windows) and It worked, I change the runner from ubuntu to windows and also worked.

and this action has more than 10 months without receiving an update but the runner from github gets updates almost every day.

so in summary: I think it was a change on Ubuntu runners that doesn't allow this action to run properly, just change you runner to windows.

runs-on: ubuntu-latest

And you may have to change some things on your workflow if you have some Linux command dependencies, I share how I have mine right now.

I hope this works for you as well as it worked for me.

# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: Deploy to Contabo

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

env:
  NUGET_URL: "https://nuget.devexpress.com/api"

jobs:
  build:

    runs-on: windows-latest

    steps:
    - name: Ensure GitHub NuGet Source
      run: |
        dotnet nuget add source ${{ env.NUGET_URL }} -n DevExpressFeed -u DevExpress -p ${{ secrets.DEVEXPRESS_NUGET_KEY }} --store-password-in-clear-text

    - uses: actions/checkout@v4
    - name: Setup .NET
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: 8.0.x
    - name: Restore dependencies
      run: dotnet restore 
    - name: Build
      run: |
           cd BackTestingTraders.Blazor.Server
           dotnet build -f net8.0 -r win-x64
    - name: dotnet publish
      run: |
           cd BackTestingTraders.Blazor.Server
           dotnet publish -f net8.0 -r win-x64 -c Release --no-restore -o ../publish 

    - name: Creating Artifact
      shell: pwsh
      run: |
           mkdir Zipfiles
           cd publish
           tar -cvf ../Contabo.tar -C . .
           cd ..
           Move-Item -Path Contabo.tar -Destination Zipfiles

    - name: Publishing Artifact
      uses: garygrossgarten/github-action-scp@release
      with:
        local: Zipfiles
        remote: C:\Projects\ContaboApp
        host: ${{ secrets.SERVER_IP }}
        username: ${{secrets.SSH_USER}}
        privateKey: ${{ secrets.PRIVATE_KEY }}
        passphrase: ${{ secrets.PASSPHRASE }}
        rmRemote: true
        atomicPut: false

    - name: Deleting Published Artifact
      uses: garygrossgarten/github-action-ssh@0.7.0
      with:
        command: | 
                 tar xvf C:\Projects\ContaboApp\Contabo.tar -C C:\Projects\ContaboApp
                 del /f C:\Projects\ContaboApp\Contabo.tar 
        host: ${{ secrets.SERVER_IP }}
        username: ${{secrets.SSH_USER}}
        privateKey: ${{ secrets.PRIVATE_KEY }}
        passphrase: ${{ secrets.PASSPHRASE }}