https://github.com/favware/ssh-remote-action
A GitHub action for executing a SSH command on a remote server
https://github.com/favware/ssh-remote-action
Last synced: 9 months ago
JSON representation
A GitHub action for executing a SSH command on a remote server
- Host: GitHub
- URL: https://github.com/favware/ssh-remote-action
- Owner: favware
- License: mit
- Created: 2023-12-08T23:16:31.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-15T23:39:28.000Z (over 2 years ago)
- Last Synced: 2025-04-16T00:23:37.712Z (about 1 year ago)
- Language: Shell
- Homepage:
- Size: 22.5 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# SSH Remote Action
SSH Remote Action (ssh-remote-action) is a GitHub action for executing a SSH
command on a remote server. An example use case of this action is deploying your
application on your remote server after publishing a new release through another
GitHub workflow job.
## Usage
`.github/workflows/continuous-deployment.yml`
```yml
on:
release:
types: [published]
jobs:
publish:
name: Publish application
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
# Do whatever you need to do to publish your application
deploy:
name: Deploy on remote server
runs-on: ubuntu-latest
needs: publish
steps:
- name: Deploy on remote server
uses: favware/ssh-remote-action@v1
with:
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.SSH_KEY_PASSPHRASE }}
username: ${{ secrets.SSH_USERNAME }}
command: ${{ secrets.SSH_COMMAND }}
```
### Ensuring that the output from the command is not printed to the logs
You may not want the output of the SSH logs to be printed to the GitHub action
logs. To achieve this you can provide the `silent` input with value of `true`.
This will take your `command` and transform it to:
```sh
sh -c '${{ inputs.command }}' > /dev/null 2>&1
```
Alternatively you can also provide this directly to your SSH command, in that
case make sure you do NOT set `silent` to true. For example if we want to call a
script called `deploy.sh` the syntax is:
```sh
sh -c '/path/to/deploy.sh' > /dev/null 2>&1
```