{"id":15030040,"url":"https://github.com/easingthemes/ssh-deploy","last_synced_at":"2026-04-03T00:50:00.333Z","repository":{"id":37547889,"uuid":"210941897","full_name":"easingthemes/ssh-deploy","owner":"easingthemes","description":"GitHub Action for deploying code via rsync over ssh. (with NodeJS)","archived":false,"fork":false,"pushed_at":"2024-07-24T17:04:55.000Z","size":413,"stargazers_count":1276,"open_issues_count":2,"forks_count":156,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-11T02:01:53.669Z","etag":null,"topics":["continous-integration","continuous-deployment","deployment","ssh"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/easingthemes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-25T21:15:52.000Z","updated_at":"2025-05-10T03:42:15.000Z","dependencies_parsed_at":"2024-01-18T22:34:57.735Z","dependency_job_id":"e3039752-48c0-44be-8abd-93eb992182d5","html_url":"https://github.com/easingthemes/ssh-deploy","commit_stats":{"total_commits":262,"total_committers":26,"mean_commits":"10.076923076923077","dds":0.6259541984732824,"last_synced_commit":"a1aa0b6cf96ce2406eef90faa35007a4a7bf0ac0"},"previous_names":[],"tags_count":79,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easingthemes%2Fssh-deploy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easingthemes%2Fssh-deploy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easingthemes%2Fssh-deploy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easingthemes%2Fssh-deploy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/easingthemes","download_url":"https://codeload.github.com/easingthemes/ssh-deploy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253685217,"owners_count":21947306,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["continous-integration","continuous-deployment","deployment","ssh"],"created_at":"2024-09-24T20:12:17.947Z","updated_at":"2026-04-03T00:50:00.302Z","avatar_url":"https://github.com/easingthemes.png","language":"JavaScript","readme":"# ssh deployments\n\nDeploy code with rsync over ssh.\n\nExecute remote scripts before or after rsync\n\nNodeJS version is more than a minute `faster` than simple Docker version.\n\nThis GitHub Action deploys specific directory from `GITHUB_WORKSPACE` to a folder on a server via rsync over ssh, using NodeJS.\n\nThis action would usually follow a build/test action which leaves deployable code in `GITHUB_WORKSPACE`, eg `dist`;\n\nIn addition to rsync, this action provides scripts execution on remote host before and/or after rsync.\n\n# Configuration\n\nPass configuration with `env` vars\n\n##### 1. `SSH_PRIVATE_KEY` [required]\n\nPrivate key part of an SSH key pair.\nThe public key part should be added to the `authorized_keys` file on the server that receives the deployment.\n\nMore info for SSH keys: https://www.ssh.com/ssh/public-key-authentication\n\nThe keys should be generated using the PEM format. You can use this command\n\n```\nssh-keygen -m PEM -t rsa -b 4096\n```\n**Please Note:** You should not set a Passphrase (keep it empty) for the private key you generated.\nBecause rsync ssh (used for deploy) does not support private key password to be entered as a command line parameter.\n\n##### 2. `REMOTE_HOST` [required]\n\neg: mydomain.com\n\n##### 3. `REMOTE_USER` [required]\n\neg: myusername\n\n##### 4. `REMOTE_PORT` (optional, default '22')\n\neg: '59184'\n\n##### 5. `ARGS` (optional, default '-rlgoDzvc -i')\n\nFor any initial/required rsync flags, eg: `-avzr --delete`\n\n##### 6. `SOURCE` (optional, default '')\n\nThe source directory, path relative to `$GITHUB_WORKSPACE` root, eg: `dist/`.\nMultiple sources should be separated by space.\n\n##### 7. `TARGET` (optional, default '/home/REMOTE_USER/')\n\nThe target directory\n\n##### 8. `EXCLUDE` (optional, default '')\n\npath to exclude separated by `,`, ie: `/dist/, /node_modules/`\n\n##### 9. `SCRIPT_BEFORE` (optional, default '')\n\nScript to run on host machine before rsync. Single line or multiline commands.\nExecution is preformed by storing commands in `.sh` file and executing it via `.bash` over `ssh`\nIf you have issues with `ssh` connection, use this var, eg `SCRIPT_BEFORE: ls`.\nThis will force `known_hosts` update, adding your host via `ssh-keyscan`.\n\n##### 10. `SCRIPT_BEFORE_REQUIRED` (optional, default false)\n\nIf set to `true`, Job will fail if SCRIPT_BEFORE fails.\n\n##### 11. `SCRIPT_AFTER` (optional, default '')\n\nScript to run on host machine after rsync.\nRsync output is stored in `$RSYNC_STDOUT` env variable.\n\n##### 12. `SCRIPT_AFTER_REQUIRED` (optional, default false)\n\nIf set to `true`, Job will fail if SCRIPT_AFTER fails.\n\n##### 13. `SSH_CMD_ARGS` (optional, default '-o StrictHostKeyChecking=no')\n\nA list of ssh arguments, they must be prefixed with -o and separated by a comma, for example: -o SomeArgument=no, -o SomeOtherArgument=5\n\n\n# Usage\n\nUse the latest version from Marketplace,eg: ssh-deploy@v5.1.0\nor use the latest version from a branch, eg: ssh-deploy@main\n\n```\n  - name: Deploy to Staging server\n    uses: easingthemes/ssh-deploy@main\n    with:\n      SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}\n      ARGS: \"-rlgoDzvc -i\"\n      SOURCE: \"dist/\"\n      REMOTE_HOST: ${{ secrets.REMOTE_HOST }}\n      REMOTE_USER: ${{ secrets.REMOTE_USER }}\n      TARGET: ${{ secrets.REMOTE_TARGET }}\n      EXCLUDE: \"/dist/, /node_modules/\"\n      SCRIPT_BEFORE: |\n        whoami\n        ls -al\n      SCRIPT_AFTER: |\n        whoami\n        ls -al\n        echo $RSYNC_STDOUT\n```\n\n# Example usage in workflow\n\n```\nname: Node CI\n\non: [push]\n\njobs:\n  build:\n\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v3\n    - name: Install Node.js\n      uses: actions/setup-node@v3\n      with:\n        node-version: '16.x'\n    - name: Install npm dependencies\n      run: npm install\n    - name: Run build task\n      run: npm run build --if-present\n    - name: Deploy to Server\n      uses: easingthemes/ssh-deploy@main\n      with:\n          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}\n          ARGS: \"-rlgoDzvc -i --delete\"\n          SOURCE: \"dist/\"\n          REMOTE_HOST: ${{ secrets.REMOTE_HOST }}\n          REMOTE_USER: ${{ secrets.REMOTE_USER }}\n          TARGET: ${{ secrets.REMOTE_TARGET }}\n          EXCLUDE: \"/dist/, /node_modules/\"\n```\n\n## Issues\n\nThis is a GitHub Action wrapping `rsync` via `ssh`. Only issues with action functionality can be fixed here.\n\nAlmost 95% of the issues are related to wrong SSH connection or `rsync` params and permissions.\nThese issues are not related to the action itself.\n\n- Check manually your ssh connection from your client before opening a bug report.\n- Check `rsync` params for your use-case. Default params are not necessarily going to be enough for everyone, it highly depends on your setup.\n- Check manually your rsync command from your client before opening a bug report.\n- `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:\n  - Use `SCRIPT_BEFORE` param, eg `SCRIPT_BEFORE: ls`. This will force `known_hosts` update, adding your host via `ssh-keyscan`.\n  - Or manually add public key to authorized_keys and add a new line to a private key.\n\nI've added e2e test for this action.\nReal example is executed on every PR merge to `main`.\nCheck actions tab for example.\n\nWhen opening an issue, please add example of your step with env vars. You can add dummy values.\n\nMore info for SSH keys: https://www.ssh.com/ssh/public-key-authentication\n\n## Tips\n\n- Optional ENV variables are created for simple requirements.\nFor complex use cases, use `ARGS` and `SSH_CMD_ARGS` to fully configure `rsync` with all possible options.\n- If you need to use multiple steps, eg multi targets deployment, save shared ENV variables in `\u003e\u003e $GITHUB_ENV`.\nCheck .github/workflows/e2e.yml for an example\n- For multi sources, use -R ARG to manipulate folders structure.\n- Great post about `rsync` options specific to usage of this action: https://logansnotes.com/2020/gh-action-site-deploy/\n\n\n## Disclaimer\n\nCheck your keys. Check your deployment paths. And use at your own risk.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasingthemes%2Fssh-deploy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasingthemes%2Fssh-deploy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasingthemes%2Fssh-deploy/lists"}