scp-action icon indicating copy to clipboard operation
scp-action copied to clipboard

Can't use environment variable for target

Open Pikachews opened this issue 4 years ago • 2 comments

This does not seem to work:

    - name: Upload
      uses: appleboy/[email protected]
      with:
        host: $HOST
        username: $USERNAME
        key: ${{ secrets.STAGING_MAIN_KEY }}
        source: ${{ github.sha }}.zip
        target: $TARGET_PATH        # <---- using environment variable

(I have my env vars defined at the top-level.)

It prints the following output:

tar all files into /tmp/941631237/O7WrNb0QY9.tar
scp file to server.
create folder $TARGET_PATH
drone-scp error:  Process exited with status 1
drone-scp rollback: remove all target tmp file
remove file O7WrNb0QY9.tar
2020/06/24 06:46:37 Process exited with status 1

It says literally $TARGET_PATH in there, instead of the value of $TARGET_PATH.

Pikachews avatar Jun 24 '20 06:06 Pikachews

@Pikachews I had the same issue concatenating variables in my target, just define a global env variable like below

on:
  push:
    branches: [master]
  
env:
  PACKAGE: ${{ github.sha }}
  UPLOAD_PATH: ${{ secrets.REMOTE_API_TARGET }}/${{github.sha }}

amaurybrisou avatar Nov 10 '20 18:11 amaurybrisou

The workaround is to reference the environment variables as ${{ env.VAR }}, such as:

    - name: Upload
      uses: appleboy/[email protected]
      with:
        host: ${{ env.HOST }}
        username: ${{ env.USERNAME }}
        key: ${{ secrets.STAGING_MAIN_KEY }}
        source: ${{ github.sha }}.zip
        target: ${{ env.TARGET_PATH }}       # <---- using environment variable

jasonaycock avatar Dec 16 '20 17:12 jasonaycock