appleboy / drone-scp

Copy files and artifacts via SSH using a binary, docker or Drone CI.
MIT License
142 stars 29 forks source link

Source list wildcard doesn't seem to work #127

Closed tim-the-arcane closed 1 year ago

tim-the-arcane commented 2 years ago

Hi all!

I started using this image as plugin for Drone CI to deploy my Svelte app on the production web server.

kind: pipeline
type: docker
name: default

steps:
- name: pull and build
  image: node
  commands:
  - npm install
  - npm run build

- name: deploy to server
  image: appleboy/drone-scp
  settings:
    host:
      from_secret: ssh_host
    username:
      from_secret: ssh_user
    key:
      from_secret: ssh_key
    port: 22
    command_timeout: 2m
    target:
      from_secret: ssh_target_dir
    source:
      - build/*

It already works but it uploads the whole build folder instead of the contents of the build folder:

image

Is there any setting I'm missing? Thanks a lot for taking your time to read my issue!

serxoz commented 2 years ago

Hi.

I'm getting the same "error". @tim-the-arcane could you solve this?

Thank you in advance.

tim-the-arcane commented 2 years ago

Hi @serxoz,

indeed I got it working by adding the option strip_components after the other scp settings like this:

kind: pipeline
type: docker
name: default

steps:
  - name: pull and build
    image: node
    commands:
      - npm install
      - npm run build

  - name: deploy to production server
    image: appleboy/drone-scp
    settings:
      host:
        from_secret: ssh_host
      username:
        from_secret: ssh_user
      key:
        from_secret: ssh_key
      port: 22
      command_timeout: 2m
      target:
        from_secret: ssh_target_dir
      source: ./build/*
      strip_components: 1
    when:
      branch:
        - main

Since this change it works for me.

Maybe a better explanation of this option would help in the documentation?

serxoz commented 2 years ago

Thank you! I'll try that :D

appleboy commented 1 year ago

just add strip_components: 1 to resolve the issue.