Giter Site home page Giter Site logo

easingthemes / ssh-deploy Goto Github PK

View Code? Open in Web Editor NEW
1.2K 8.0 144.0 413 KB

GitHub Action for deploying code via rsync over ssh. (with NodeJS)

License: MIT License

JavaScript 91.27% Dockerfile 8.50% Shell 0.23%
ssh deployment continuous-deployment continous-integration

ssh-deploy's Introduction

ssh deployments

Deploy code with rsync over ssh.

Execute remote scripts before or after rsync

NodeJS version is more than a minute faster than simple Docker version.

This GitHub Action deploys specific directory from GITHUB_WORKSPACE to a folder on a server via rsync over ssh, using NodeJS.

This action would usually follow a build/test action which leaves deployable code in GITHUB_WORKSPACE, eg dist;

In addition to rsync, this action provides scripts execution on remote host before and/or after rsync.

Configuration

Pass configuration with env vars

1. SSH_PRIVATE_KEY [required]

Private key part of an SSH key pair. The public key part should be added to the authorized_keys file on the server that receives the deployment.

More info for SSH keys: https://www.ssh.com/ssh/public-key-authentication

The keys should be generated using the PEM format. You can use this command

ssh-keygen -m PEM -t rsa -b 4096

Please Note: You should not set a Passphrase (keep it empty) for the private key you generated. Because rsync ssh (used for deploy) does not support private key password to be entered as a command line parameter.

2. REMOTE_HOST [required]

eg: mydomain.com

3. REMOTE_USER [required]

eg: myusername

4. REMOTE_PORT (optional, default '22')

eg: '59184'

5. ARGS (optional, default '-rlgoDzvc -i')

For any initial/required rsync flags, eg: -avzr --delete

6. SOURCE (optional, default '')

The source directory, path relative to $GITHUB_WORKSPACE root, eg: dist/. Multiple sources should be separated by space.

7. TARGET (optional, default '/home/REMOTE_USER/')

The target directory

8. EXCLUDE (optional, default '')

path to exclude separated by ,, ie: /dist/, /node_modules/

9. SCRIPT_BEFORE (optional, default '')

Script to run on host machine before rsync. Single line or multiline commands. Execution is preformed by storing commands in .sh file and executing it via .bash over ssh If you have issues with ssh connection, use this var, eg SCRIPT_BEFORE: ls. This will force known_hosts update, adding your host via ssh-keyscan.

10. SCRIPT_BEFORE_REQUIRED (optional, default false)

If set to true, Job will fail if SCRIPT_BEFORE fails.

11. SCRIPT_AFTER (optional, default '')

Script to run on host machine after rsync. Rsync output is stored in $RSYNC_STDOUT env variable.

12. SCRIPT_AFTER_REQUIRED (optional, default false)

If set to true, Job will fail if SCRIPT_AFTER fails.

13. SSH_CMD_ARGS (optional, default '-o StrictHostKeyChecking=no')

A list of ssh arguments, they must be prefixed with -o and separated by a comma, for example: -o SomeArgument=no, -o SomeOtherArgument=5

Usage

Use the latest version from Marketplace,eg: [email protected] or use the latest version from a branch, eg: ssh-deploy@main

  - name: Deploy to Staging server
    uses: easingthemes/ssh-deploy@main
    with:
      SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
      ARGS: "-rlgoDzvc -i"
      SOURCE: "dist/"
      REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
      REMOTE_USER: ${{ secrets.REMOTE_USER }}
      TARGET: ${{ secrets.REMOTE_TARGET }}
      EXCLUDE: "/dist/, /node_modules/"
      SCRIPT_BEFORE: |
        whoami
        ls -al
      SCRIPT_AFTER: |
        whoami
        ls -al
        echo $RSYNC_STDOUT

Example usage in workflow

name: Node CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Install Node.js
      uses: actions/setup-node@v3
      with:
        node-version: '16.x'
    - name: Install npm dependencies
      run: npm install
    - name: Run build task
      run: npm run build --if-present
    - name: Deploy to Server
      uses: easingthemes/ssh-deploy@main
      with:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
          ARGS: "-rlgoDzvc -i --delete"
          SOURCE: "dist/"
          REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
          REMOTE_USER: ${{ secrets.REMOTE_USER }}
          TARGET: ${{ secrets.REMOTE_TARGET }}
          EXCLUDE: "/dist/, /node_modules/"

Issues

This is a GitHub Action wrapping rsync via ssh. Only issues with action functionality can be fixed here.

Almost 95% of the issues are related to wrong SSH connection or rsync params and permissions. These issues are not related to the action itself.

  • Check manually your ssh connection from your client before opening a bug report.
  • Check rsync params for your use-case. Default params are not necessarily going to be enough for everyone, it highly depends on your setup.
  • Check manually your rsync command from your client before opening a bug report.
  • Deployment Failed, Permission denied (publickey,password): This issue occures in some cases, it is related to OS and ssh. This action can only provide a workaround:
    • Use SCRIPT_BEFORE param, eg SCRIPT_BEFORE: ls. This will force known_hosts update, adding your host via ssh-keyscan.
    • Or manually add public key to authorized_keys and add a new line to a private key.

I've added e2e test for this action. Real example is executed on every PR merge to main. Check actions tab for example.

When opening an issue, please add example of your step with env vars. You can add dummy values.

More info for SSH keys: https://www.ssh.com/ssh/public-key-authentication

Tips

  • Optional ENV variables are created for simple requirements. For complex use cases, use ARGS and SSH_CMD_ARGS to fully configure rsync with all possible options.
  • If you need to use multiple steps, eg multi targets deployment, save shared ENV variables in >> $GITHUB_ENV. Check .github/workflows/e2e.yml for an example
  • For multi sources, use -R ARG to manipulate folders structure.
  • Great post about rsync options specific to usage of this action: https://logansnotes.com/2020/gh-action-site-deploy/

Disclaimer

Check your keys. Check your deployment paths. And use at your own risk.

ssh-deploy's People

Contributors

aperezdc avatar armadillidiid avatar contention avatar dbryan0516 avatar dependabot[bot] avatar easingthemes avatar fmal avatar garryone avatar jeromelachaud avatar jzleung avatar mansandersson avatar npiasecki avatar olivertappin avatar perlun avatar peterkracik avatar sdelfi avatar sebastianblesgen avatar shoshins avatar skyarony avatar triloworld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ssh-deploy's Issues

GIT submodule & .git folder

Good day everyone!

I'd like to mention two things here and would like to request fixing them (at least the one with .git folder):

  1. When I'm specifying .git/ folder to be excluded while deployment it still appears on the server (I've tried EXCLUDE: ".git/" and EXCLUDE: "/.git/" - both options end up with the same result).
  2. I've got submodule in my project and after deployment folder appears to be empty at all. However in fact it points to another git folder which also must be deployed.

More description about SSH_PRIVATE_KEY

SSH_PRIVATE_KEY [required]
This should be the private key part of an ssh key pair. The public key part should be added to the authorized_keys file on the server that receives the deployment.

The keys should be generated using the PEM format. You can use this command

ssh-keygen -m PEM -t rsa -b 4096

Hi, I'm a newbie in networking, so it took me a while to figure out what should be done here.

I'll try to explain what I understood, maybe it will be helpful to someone else 🙂

I run ssh-keygen -m PEM -t rsa -b 4096 locally, and saved keys into a new folder (not to mess up with existing ones).
Then the private key, I put in GitHub secrets. And the public one I added to my server .ssh/authorized_keys file.

Initially, I was trying to generate keys on the server as well 😅. And couldn't understand why it's not working.

That's it 🙃 I think it's would be too silly to put in readme file, so I did it in the issue.

Github action ssh-deploy Security group of Ec2 instance

In order to use easingthemes
/ssh-deploy
, what IPs should be allowed in EC2 instance security group where we want to deploy code.
Since GitHUB action runner can assume any IP, does it mean that we need to allow SSH on our server from whole internet. is there any workaround for this

Excludes ignored

I have following configuration:
image

and despite having node_modules in excludes, it still copies it over to server. How can I disable it?

Rsync Action fails with Cannot read property 'match' of undefined

I am running into an error on the Rsync Action and cannot figure out what is causing it.
I followed your instructions on creating a key, ensured the directory paths were correct, but each time I get the same error.

My workflow:

name: SSH Deployment

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1

      - name: Install Node.js
        uses: actions/setup-node@v1
        with:
          node-version: "12.x"

      - name: Install dependencies
        run: yarn

      - name: Build site
        run: yarn build

      - name: Deploy to Production server
        uses: easingthemes/[email protected]
        env:
          SSH_PRIVATE_KEY: ${{ secrets.RANDOM_CALC_DEPLOY_KEY }}
          SOURCE: "dist/"
          REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
          REMOTE_USER: ${{ secrets.REMOTE_USER }}
          TARGET: ${{ secrets.TARGET }}

the build output:
image

Unable to deploy

I'm able to successfully connect using PuTTY from my local machine, but using the same credentials I cannot deploy, for some reason. Logs are as follows:

⚠️ [Rsync] error: rsync exited with code 255
⚠️ [Rsync] stderr: Warning: Permanently added '[***]:18765,[35.214.39.221]:18765' (ED25519) to the list of known hosts.
@: Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.3]

⚠️ [Rsync] stdout:
⚠️ [Rsync] cmd: rsync /home/runner/work/hopemill/hopemill/ @:www/chrisb222.sg-host.com/public_html/ --rsh "ssh -p 18765 -i /home/runner/.ssh/deploy_key -o StrictHostKeyChecking=no" --recursive --exclude= -rltgoDzvO
1: 0x9da7c0 node::Abort() [/home/runner/runners/2.283.2/externals/node12/bin/node]
2: 0xa4e219 [/home/runner/runners/2.283.2/externals/node12/bin/node]
3: 0xba5d59 [/home/runner/runners/2.283.2/externals/node12/bin/node]
4: 0xba7b47 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.283.2/externals/node12/bin/node]
5: 0x13750d9 [/home/runner/runners/2.283.2/externals/node12/bin/node]

iprange to whitelist

what is your iprange to whitelist for ssh.
we would like to whitelist in our server, then we will configure

Ability to add ssh option

Hi,

So I've been trying to find a way to add an ssh option (-o) to the rsync cmd args, is there a way that I don't know about or is not documented yet?

My goal is to add this ssh option: -o KexAlgorithms=ecdh-sha2-nistp521 in order to fix a bug with rsync when connecting to the ssh host, I can see that the rsync is using by default, this cmd line option --rsh "ssh -p 22 -i /runner/.ssh/deploy_key -o StrictHostKeyChecking=no"..

I would appreciate any guiding on that, thanks in advance

Rsync Error: Permission Denied (13)

I have been using the same deployment configuration without a single change for months now. The destination server also hasn't had any changes in that amount of time. Yet when I run these actions:

      - name: Prepare SSH
        run: >
          cd ~ && mkdir .ssh &&
          touch ~/.ssh/known_hosts &&
          ssh-keyscan -H "$IP" >>~/.ssh/known_hosts
        env:
          IP: ${{ secrets.IP }}

      - name: SSH Deploy
        uses: easingthemes/[email protected]
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
          ARGS: >-
            -rptgoDOqi
            --chown=www-data:www-data
            --fake-super
            --exclude='.git'
            --exclude='.env'
            --exclude='storage/logs'
            --exclude='storage/framework/cache/data'
            --exclude='bootstrap/cache/*'
            --exclude='node_modules/'
            --exclude='vendor/'
            --del
          SOURCE: "./"
          REMOTE_HOST: ${{ secrets.IP }}
          REMOTE_USER: ${{ secrets.USER_NAME }}
          TARGET: ${{ secrets.DEPLOY_PATH }}

This is the result:

2021-04-09T15:43:12.6097374Z [general] GITHUB_WORKSPACE:  /home/runner/work/aa/aa
2021-04-09T15:43:12.6141428Z [SSH] /home/runner/.ssh dir exist
2021-04-09T15:43:12.6144249Z [SSH] /home/runner/.ssh/known_hosts file exist
2021-04-09T15:43:12.6159475Z ✅ Ssh key added to `.ssh` dir  /home/runner/.ssh/deploy_key
2021-04-09T15:43:12.6160778Z [Rsync] Starting Rsync Action: /home/runner/work/aa/aa/./ to ***@***:***
2021-04-09T15:43:12.6161457Z [Rsync] exluding folders 
2021-04-09T15:43:14.1354675Z ⚠️ [Rsync] error:  rsync exited with code 3
2021-04-09T15:43:14.1356792Z ⚠️ [Rsync] stderr:  rsync: ERROR: cannot stat destination "***": Permission denied (13)
2021-04-09T15:43:14.1357799Z rsync error: errors selecting input/output files, dirs (code 3) at main.c(653) [Receiver=3.1.2]
2021-04-09T15:43:14.1358483Z 
2021-04-09T15:43:14.1359256Z ⚠️ [Rsync] stdout:  
2021-04-09T15:43:14.1362788Z ⚠️ [Rsync] cmd:  rsync /home/runner/work/aa/aa/./ ***@***:*** --rsh "ssh -p 22 -i /home/runner/.ssh/deploy_key -o StrictHostKeyChecking=no" --recursive --exclude= -rptgoDOqi --chown=www-data:www-data --fake-super --exclude='.git' --exclude='.env' --exclude='storage/logs' --exclude='storage/framework/cache/data' --exclude='bootstrap/cache/*' --exclude='node_modules/' --exclude='vendor/' --del
2021-04-09T15:43:14.2565366Z  1: 0x9da7c0 node::Abort() [/home/runner/runners/2.277.1/externals/node12/bin/node]
2021-04-09T15:43:14.2566863Z  2: 0xa4e219  [/home/runner/runners/2.277.1/externals/node12/bin/node]
2021-04-09T15:43:14.2571911Z  3: 0xba5d59  [/home/runner/runners/2.277.1/externals/node12/bin/node]
2021-04-09T15:43:14.2577444Z  4: 0xba7b47 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.277.1/externals/node12/bin/node]
2021-04-09T15:43:14.2594782Z  5: 0x13750d9  [/home/runner/runners/2.277.1/externals/node12/bin/node]
2021-04-09T15:43:14.7021655Z Post job cleanup.

I've also tried updating ssh-deploy to v2.1.6 with the same result. What happened?

Deployment failure

My purpose is to hope Github Actions can deploy Hexo blog into Ali Cloud server, according to the documentation my actions file is as follows:

name: Aliyun Server CI

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Install Node.js
      uses: actions/setup-node@v1
      with:
        node-version: '16.x'
    - name: Install npm dependencies
      run: npm install
    - name: Run build task
      run: npm run build --if-present
    - name: Deploy to Server
      uses: easingthemes/ssh-deploy@main
      env:
          SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
          ARGS: "-rltgoDzvO --delete"
          SOURCE: "dist/"
          REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
          REMOTE_USER: ${{ secrets.REMOTE_USER }}
          EXCLUDE: "/dist/, /node_modules/"

And added three Actions secrets to the GitHub repository, their configuration is as follows:

name value
SERVER_SSH_KEY Use ssh-keygen -m PEM -t rsa -b 4096 to generate secrets on the server and paste the id_rsa into github Actions. However, there was no authorized_keys file in my server's.ssh directory, so I created a new authorized_keys file in the .ssh directory and pasted the id_rsa.pub file contents into authorized_keys
REMOTE_HOST My website uses CDN service, and HERE I fill in coder-jason.cn
RREMOTE_USER It's a random nickname I made up: jason

Github Actions log is as follows:

⚠️ [Rsync] error:  rsync exited with code 255
⚠️ [Rsync] stderr:  ssh: connect to host *** port [22](https://github.com/PDPENG/MyBlog/runs/6587206440?check_suite_focus=true#step:6:23): Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c([23](https://github.com/PDPENG/MyBlog/runs/6587206440?check_suite_focus=true#step:6:24)5) [sender=3.1.3]

⚠️ [Rsync] stdout:  
⚠️ [Rsync] cmd:  rsync /home/runner/work/MyBlog/MyBlog/dist/ ***@***:/home/REMOTE_USER/ --rsh "ssh -p 22 -i /home/runner/.ssh/deploy_key -o StrictHostKeyChecking=no" --recursive --exclude= -rltgoDzvO --delete
 1: 0xa1a640 node::Abort() [/home/runner/runners/2.[29](https://github.com/PDPENG/MyBlog/runs/6587206440?check_suite_focus=true#step:6:30)1.1/externals/node12/bin/node]
 2: 0xa90649  [/home/runner/runners/2.291.1/externals/node12/bin/node]
 3: 0xc06599  [/home/runner/runners/2.291.1/externals/node12/bin/node]
 4: 0xc08387 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.291.1/externals/node12/bin/node]
 5: 0x140dd19  [/home/runner/runners/2.291.1/externals/node12/bin/node]

I look forward to your reply, thank you!

Rsync is just emptying folder, not copying anything

I might be doing this wrong (probably), but every time this workflow executes, the destination folder is just empty.
Here is my workflow:

name: SSH Deploy
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: ssh deploy
        uses: easingthemes/[email protected]
        with:
          SSH_PRIVATE_KEY: ${{secrets.SERVER_SSH_KEY}}
          REMOTE_HOST: ${{secrets.REMOTE_HOST}}
          REMOTE_USER: ${{secrets.REMOTE_USER}}
          REMOTE_PORT: 22
          TARGET: ${{secrets.REMOTE_TARGET}}
          ARGS: "-rltgoDzvO" # optional, default is -rltgoDzvO

The logs look like this:

 1: Run easingthemes/[email protected]
10: [general] GITHUB_WORKSPACE:  /home/runner/work/AllKnowingRedditBot/AllKnowingRedditBot
11: [SSH] Creating /home/runner/.ssh dir in  /home/runner/work/AllKnowingRedditBot/AllKnowingRedditBot
12: ✅ [SSH] dir created.
13: [SSH] Creating /home/runner/.ssh/known_hosts file in  /home/runner/work/AllKnowingRedditBot/AllKnowingRedditBot
14: ✅ [SSH] file created.
15: ✅ Ssh key added to `.ssh` dir  /home/runner/.ssh/deploy_key
16: [Rsync] Starting Rsync Action: /home/runner/work/AllKnowingRedditBot/AllKnowingRedditBot/ to ***@***:***
17: ✅ [Rsync] finished. sending incremental file list

I think the problem could be that GITHUB_WORKSPACE is a double nested folder (AllKnowingRedditBot/AllKnowingRedditBot), but further than that, I'm really lost here.

Rsync error status code 255

actions config

  with:
    TARGET: /home/REMOTE_USER/
  env:
    SSH_PRIVATE_KEY: ***
    ARGS: -avz --delete
    REMOTE_USER: ***
    REMOTE_HOST: ***
    SOURCE: .vuepress/dist
    TARGET: /usr/share/nginx/html

actions error log

GITHUB_WORKSPACE /home/runner/work/vpblog/vpblog
Creating /home/runner/.ssh dir in  /home/runner/work/vpblog/vpblog
Creating /home/runner/.ssh/known_hosts file in  /home/runner/work/vpblog/vpblog
✅ Ssh key added to `.ssh` dir  /home/runner/.ssh/deploy_key
Starting Rsync Action: /home/runner/work/vpblog/vpblog/.vuepress/dist to ***@***:/usr/share/nginx/html
⚠️ Rsync error rsync exited with code 255
 1: 0x9da7c0 node::Abort() [/home/runner/runners/2.267.1/externals/node12/bin/node]
 2: 0xa4e219  [/home/runner/runners/2.267.1/externals/node12/bin/node]
 3: 0xba5d59  [/home/runner/runners/2.267.1/externals/node12/bin/node]
 4: 0xba7b47 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.267.1/externals/node12/bin/node]
 5: 0x13750d9  [/home/runner/runners/2.267.1/externals/node12/bin/node]

Delete Git logs and permission error after deploy

I even succeeded in deploying on the production server. However, an unknown phenomenon occurs after deployment to the server.

  1. When inquiring with the git log command, all previous logs disappeared except for the last commit log.

  2. The error below continues to occur during the login process when I pull or fetch.

Username for 'https://github.com': jay-flow
Password for 'https://[email protected]':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/repo/'

I checked my user name and password on my account several times and it works well elsewhere. I'm sure I typed it correctly.


Is there anyone who knows how to solve this problem? Please let me know.
(I think it caused the problem by deploying the .git folder together. But I don't know how to solve this)

Below is my Action It is deployed normally.

# This is a basic workflow to help you get started with Actions

name: Deploy to AWS EC2

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]


# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
     
      - name: Deploy to back end
        uses: easingthemes/[email protected]
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
          REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
          REMOTE_USER: ${{ secrets.REMOTE_USER }}
          TARGET: ${{ secrets.TARGET }}

contain virus and malware

Your plugin has some serious issue after 5 days of installation, it's trying to access other users system port sshd using our server's network.

npm WARN saveError ENOENT: no such file or directory, open '/home/runner/work...'

Hello,

I'm trying your action in 2.1.6 version and got this error message:

0s
Run npm run build --if-present
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/runner/work/sme/sme/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/work/sme/sme/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-05-08T10_43_26_639Z-debug.log
Error: Process completed with exit code 254.

Could you please help me to solve it?

Feature Request - Connect to SSH Host through Jump-box

Hi,

It would be nice if we could setup a jump-box ssh tunnel to send the artefacts to the destiny host.

Something like this:

- name: Deploy through Jump-box
         ...
          uses: easingthemes/ssh-deploy@main
          jumpbox: 
            SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
            REMOTE_HOST: ${{ secrets.REMOTE_HOST_DEVELOP }}
            REMOTE_USER: ${{ secrets.REMOTE_USER_DEVELOP }}
          ... 

Build stays in "Starting Rsync Action" forever

I am new to Actions and I really don't know what I am doing wrong. Initially I had a authentication error but then I saw that I needed to provide the private key instead of the public one, ok! But now my build runs forever when reach "[Rsync] Starting Rsync Action:" part and nothing is really copied to my server.

cant't deploy

[Rsync] Starting Rsync Action: /home/runner/work/primect/primect/./src/ to [email protected]:/home/ubuntu/primect
⚠️ [Rsync] error: rsync exited with code 255
⚠️ [Rsync] stderr: ssh: connect to host ecxxxxxxx.eu-north-1.compute.amazonaws.com port 22: Connection timed out
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.3]

⚠️ [Rsync] stdout:
⚠️ [Rsync] cmd: rsync /home/runner/work/primect/primect/./src/ [email protected]:/home/ubuntu/primect --rsh "ssh -p 22 -i /home/runner/.ssh/deploy_key -o StrictHostKeyChecking=no" --recursive -av

How to deploy on multiple servers

      - name: Deploy static to Server_1
        uses: easingthemes/[email protected]
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
          ARGS: "-avz --delete"
          SOURCE: "dist/"
          REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
          REMOTE_USER: ${{ secrets.REMOTE_USER }}
          TARGET: ${{ secrets.TARGET }}

      - name: Deploy static to Server_2
        uses: easingthemes/[email protected]
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY2 }}
          ARGS: "-avz --delete"
          SOURCE: "dist/"
          REMOTE_HOST: ${{ secrets.REMOTE_HOST2 }}
          REMOTE_USER: ${{ secrets.REMOTE_USER2 }}
          TARGET: ${{ secrets.TARGET }}

Can I change it to array configuration

Additional ARGS not work

When i run locally rsync -avzr --delete --exclude={'docker/data','docker/logs','.env','config.yaml','vendor','.git'} ./ ...
rsync normally push changes at remote server
image

When run from github action same command (config attached) i see only deletions
image
as if all arguments don't work except --delete

if I remove the attribute --delete, the changes do not come to the server

name: Deploy

on:
  push:
    branches: [ develop ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - name: Deploy to Server
      uses: easingthemes/[email protected]
      env:
          SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
          REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
          REMOTE_USER: ${{ secrets.REMOTE_USER }}
          TARGET: ${{ secrets.REMOTE_TARGET }}
          SOURCE: "./"
          ARGS: "-avzr --delete --exclude={'docker/data','docker/logs','.env','config.yaml','vendor','.git'}"
       

Does not run command in ssh?

Does not run command in ssh?

Hello, excellent work this script to deploy, I have used it in PHP project and it has worked wonderfully.

I recently decided to use your deploy script for golang application, it runs perfectly without any error, sends the binary to the server in the specified path.

What happens is a snippet of code I added for it to run the binary in the background. It doesn't run, could you help me find out what I've been doing wrong?

Here's the script I'm using, thank you in advance for your attention. Hug.

name: 🚀 Deploy on push

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: ssh deploy
        uses: easingthemes/[email protected]
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
          REMOTE_HOST: ${{ secrets.SSH_HOST }}
          REMOTE_USER: ${{ secrets.SSH_USER }}
          REMOTE_PORT: ${{ secrets.HOST_PORT }}
          SOURCE: "/go.realm.com.br"
          TARGET: ${{ secrets.DEPLOY_TARGET }}
          run: |
            cd .. && 
            cd /home/username && 
            chmod +x /home/username/go.realm.com.br && 
            nohup ./go.realm.com.br &

Rsync: command not found

Hello guys,

my deployment is also not working anymore. I'm getting the following error:

⚠️ [Rsync] error:  rsync exited with code 12
⚠️ [Rsync] stderr:  Warning: Permanently added '[***]:***,[xxx.xx.xxx.xxx]:***' (ECDSA) to the list of known hosts.
bash: line 1: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.3]

Do you have any ideas?

Warning: Permanently added '***' (ECDSA) to the list of known hosts

2020-10-22T07:41:24.5568739Z [Rsync] Starting Rsync Action: /home/runner/work/oa/oa/dist/ to ***@***:***
2020-10-22T07:41:31.1770919Z ⚠️ [Rsync] error:  rsync exited with code 23
2020-10-22T07:41:31.1773617Z ⚠️ [Rsync] stderr:  Warning: Permanently added '***' (ECDSA) to the list of known hosts.
2020-10-22T07:41:31.1775129Z rsync: chgrp "***/." failed: Operation not permitted (1)
2020-10-22T07:41:31.1776683Z rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]
2020-10-22T07:41:31.1777553Z 
2020-10-22T07:41:31.1778526Z ⚠️ [Rsync] stdout:  sending incremental file list

bash: rsync: command not found

⚠️ [Rsync] error: rsync exited with code 12
⚠️ [Rsync] stderr: Warning: Permanently added '***' (ECDSA) to the list of known hosts.
bash: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.3]

Keeping version up to date

Hello there, great tool.

Is there a way to publish a "latest" tag when you deploy to the market place? That way one can always use the latest version.

The README also lags behind a bit, currently pointing to v2.1.15 as against v2.1.16

More than one REMOTE_HOST

Is it possible to use more than one REMOTE_HOST variable, for when we would have more than one host we want to deploy to?

rsync exited with code 255

Stack information when the error occurred

⚠️ [Rsync] error:  rsync exited with code 255
⚠️ [Rsync] stderr:  Permission denied, please try again.
Permission denied, please try again.
***@***: Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.3]

⚠️ [Rsync] stdout:  
⚠️ [Rsync] cmd:  rsync /home/runner/work/course-selecting-system-fe/course-selecting-system-fe/build/ ***@***:*** --rsh "ssh -p *** -i /home/runner/.ssh/deploy_key -o StrictHostKeyChecking=no" --recursive -rltgoDzvO --delete
 1: 0x9da7c0 node::Abort() [/home/runner/runners/2.277.1/externals/node12/bin/node]
 2: 0xa4e219  [/home/runner/runners/2.277.1/externals/node12/bin/node]
 3: 0xba5d59  [/home/runner/runners/2.277.1/externals/node12/bin/node]
 4: 0xba7b47 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.277.1/externals/node12/bin/node]
 5: 0x13750d9  [/home/runner/runners/2.277.1/externals/node12/bin/node]

Related action configuration

    - name: Prepare SSH
      run: >
          cd ~ && mkdir .ssh &&
          touch ~/.ssh/known_hosts &&
          ssh-keyscan -H "$IP" >>~/.ssh/known_hosts
      env:
          IP: ${{ secrets.DEPLOY_HOST }}

    - name: deploy
      uses: easingthemes/[email protected]
      env:
        SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
        ARGS: "-rltgoDzvO --delete"
        TARGET: ${{ secrets.DEPLOY_DEST_PATH }}
        REMOTE_HOST: ${{ secrets.DEPLOY_HOST }}
        REMOTE_USER: ${{ secrets.DEPLOY_USERNAME }}
        PORT: ${{ secrets.DEPLOY_PORT }}
        SOURCE: 'build/'

And I set PubkeyAuthentication yes in sshd_config file.

Build keeps failing to Flywheel

[INPUTS] SSH_PRIVATE_KEY is mandatory
⚠️ [INPUTS] REMOTE_USER is mandatory
⚠️ [INPUTS] Inputs not valid, aborting ...

I have been following this doc https://getflywheel.com/wordpress-support/deploying-to-flywheel-via-ssh-and-github-actions/ to deploy to my website hosted on Flywheel. It is an organization and I know my SSH_USER is correct, team+org-name+site-name which is what I have. I am pretty sure my SSH_REMOTE_KEY is incorrect. Currently I have my id_ed25519 private key pasted in the secret. But it is saying to have it in PEM version. When I run this command in my Terminal on my Macbook Pro 2019, I get this error:

Command: openssl rsa -in ~/.ssh/id_rsa -outform pem | pbcopy
Response: unable to load Private Key
4658441900:error:09FFF06C:PEM routines:CRYPTO_internal:no start line:/System/Volumes/Data/SWE/macOS/BuildRoots/2288acc43c/Library/Caches/com.apple.xbs/Sources/libressl/libressl-56.60.2/libressl-2.8/crypto/pem/pem_lib.c:684:Expecting: ANY PRIVATE KEY

I am not that great with GIT workflows, this is my first set up for a workflow so bear with me. But can anyone tell me why this is wrong?????

My private key that I pasted into my secrets within my Repo:

-----BEGIN OPENSSH PRIVATE KEY-----
long key code goes here, removed for security
-----END OPENSSH PRIVATE KEY-----

Everything else is working great. I am able to check in code, check out code, edit, add, delete. I really need to be able to deploy.

Feature request: option to run mkdir -p before sync

I use ssh-deploy for a while now, it is great! However I've one issue. If the remote directory path not fully exists it fails. In my case the branch name is part of the remote path. Whenever a new branch is create the deployment fails because the branch dir doesn't exist remotely. This can be solved by manually creating the directory, however it would be great if ssh-deply can handle it by running mkdir -p <path> over ssh before the sync :)

Console log when the branch dir interface-controller doesn't exists:

[Rsync] Starting Rsync Action: /home/runner/work/traintastic/traintastic/dist/* to ***@***:***/traintastic/interface-controller/211/
[Rsync] exluding folders 
⚠️ [Rsync] error:  rsync exited with code 11
⚠️ [Rsync] stderr:  Warning: Permanently added '[***]:***,[51.195.100.163]:***' (ECDSA) to the list of known hosts.
rsync: mkdir "***/traintastic/interface-controller/211" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(682) [Receiver=3.1.3]

I

Please what am I missing? I'm getting the error below:

[general] GITHUB_WORKSPACE:  /home/runner/work/wordpress/wordpress
[SSH] /home/runner/.ssh dir exist
[SSH] /home/runner/.ssh/known_hosts file exist
✅ Ssh key added to `.ssh` dir  /home/runner/.ssh/deploy_key
[Rsync] Starting Rsync Action: /home/runner/work/wordpress/wordpress/dist/ to ***@***:/home/REMOTE_USER/
⚠️ [Rsync] error:  rsync exited with code 255
⚠️ [Rsync] stderr:  Load key "/home/runner/.ssh/deploy_key": invalid format
Permission denied, please try again.
Permission denied, please try again.
***@***: Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.3]

Bad authentication type; allowed types: ['publickey']

I'm getting this error.

Bad authentication type; allowed types: ['publickey']

With this config

      - name: scp pipelines
                uses: cross-the-world/[email protected]
                   with:
                    host: ${{ secrets.DO_HOST }}
                  user: ${{ secrets.DO_USER }}
                  key: ${{ secrets.SSH_KEY }}
                  scp: |
      './client/dist/green-client/*' => /home/github/admin/client/dist

Any suggestions?

Run cross-the-world/[email protected]
  with:
    host: ***
    user: ***
    key: ***
    scp: './client/dist/green-client/*' => /home/***/admin/client/dist
  
    port: 22
    connect_timeout: 30s
  env:
    working-directory: ./client
/usr/bin/docker run --name a33c1dc07c228dad94bfb95d982cd162088fa_7f679a --label 8a33c1 --workdir /***/workspace --rm -e working-directory -e INPUT_HOST -e INPUT_USER -e INPUT_KEY -e INPUT_SCP -e INPUT_PORT -e INPUT_PASS -e INPUT_CONNECT_TIMEOUT -e INPUT_FIRST_SSH -e INPUT_LAST_SSH -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_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_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -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/_***_home":"/***/home" -v "/home/runner/work/_temp/_***_workflow":"/***/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/***/file_commands" -v "/home/runner/work/admin/admin":"/***/workspace" 8a33c1:dc07c228dad94bfb95d982cd162088fa
+++++++++++++++++++STARTING PIPELINES+++++++++++++++++++
SSH-SCP-SSH no first_ssh input found
+++++++++++++++++++Pipeline: RUNNING SCP+++++++++++++++++++
Connect error
Bad authentication type; allowed types: ['publickey']
+++++++++++++++++++END PIPELINES+++++++++++++++++++

Error: The log was not found. It may have been deleted based on retention settings.

Hello,

Here's my yml file:

name: Deploy

on:
  push:
    branches:
      - master

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - name: Install Node.js
        uses: actions/setup-node@v1
        with:
          node-version: '10.x'
      - name: Install npm dependencies
        run: npm install
      - name: npm init
        run: npm init -y
      - name: Run build task
        run: npm run build --if-present
      - name: Deploy to Server
        uses: easingthemes/[email protected]
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
          ARGS: "-avz"
          REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
          REMOTE_PORT: ${{ secrets.REMOTE_PORT }}
          REMOTE_USER: ${{ secrets.REMOTE_USER }}
          TARGET: ${{ secrets.REMOTE_TARGET }}
          EXCLUDE: "/dist/, /node_modules/"

At the end of the deployment, I've the error: Error: The log was not found. It may have been deleted based on retention settings.
screenshot-2021-05-08-14-39

Do you know why ?

getting issue while trying to push my file to server

I'am using this action from very long time but from yesterday i'am getting some issue so that i'am not able to transfer my files through this action
deploy
acion
then i have used other action which is worked fine.so can please check the issue and give feedback to me

Deployment Failed; Unauthorized

I am getting an issue with deployment due to being unauthorized on the vps I am deploying to, I created a private / public key pair on my local machine and copied the public key to my the authorized_keys file on the vps I am deploying to which is running debian, I am also running debian on my local machine. I stored the private key as a secret in github. On push, all steps work correctly except deployment and it returns unauthorized. I believe it is because I have not supplied the key password which I am not sure how to do.

Transfer multiple items but not all (source, exclude, include?)

I'd like to transfer /app/ and /public_html/.
Besides these folders are a slowly growing list of dev files like package.json and pnpm-lock.yaml.

I know I could add every single file/folder that I don't want to the exclude list, but that would mean editing the workflow many times.

Is there a solution to this?

  • Could be to allow multiple source locations. ['/app/', '/public_html/']
  • Could be to allow the ! operator to reverse functionality in the EXCLUDE arg. [*, !/app/, !/public_html/]
  • Could be to add an INCLUDE option.

I don't think any of these work at the moment.

property source can support muti-folder?

env: SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }} ARGS: "-rltgoDzvO --delete" SOURCE: "dist/" REMOTE_HOST: ${{ secrets.REMOTE_HOST }} REMOTE_USER: ${{ secrets.REMOTE_USER }} TARGET: ${{ secrets.REMOTE_TARGET }}
I want upload the .nuxt & static & package.json & nuxt.config.js folder or file which is in the root path,so how can i do it?

Post-deployment commands

In some projects, it is necessary to run commands after deployment. I'm creating another step just to run the post-deployment steps. But it would be nice to have the deployment and execution in just one step.

python version

are there any python version for this, I have a python script that needs to run on the server once per day

Multi-Destination deploy

How can I deploy one code base into multiple destinations?
for example, we have a project we want to deploy into the following domains:
example1.com
example2.com
example3.com
...
but the domain list is not static maybe get it from a dynamic list or something like that.

SOURCE not really optional

Hi, I have left out SOURCE and the rsync command fails during deployment

[Rsync] Starting Rsync Action: /home/runner/work/my-app/my-app/undefined 
rsync: link_stat "/home/runner/work/my-app/my-app/undefined" failed: No such file or directory (2)
⚠️ [Rsync] cmd:  rsync /home/runner/work/my-app/my-app/undefined

I had to set SOURCE: '' to fix it

deploy to server is slowly

when I use this action, deploy to server always spend many time.
image

And my yml is as follows:

name: deploy
on:
  push:
    branches:
      - master
    paths-ignore:   # 变更不触发部署
      - README.md
  pull_request:
    branches:
      - master
    paths-ignore:   # 变更不触发部署
      - README.md
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@master
      - name: cache node_modules
        uses: actions/cache@v2
        with:
          path: '**/node_modules'
          key: ${{ runner.os }}-modules-${{ hashFiles('**/package.json') }}
      - name: install dependencies
        run: npm install
      - name: build
        run: npm run build
      - name: Deploy to Server
        uses: easingthemes/[email protected]
        env:
            SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
            SOURCE: "build/"
            REMOTE_HOST: ${{ secrets.SSH_HOST }}
            REMOTE_USER: ${{ secrets.SSH_USERNAME }}
            TARGET: ${{ secrets.REMOTE_TARGET }}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.