Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
server

GitHub Action

Server Shell

v1

Server Shell

server

Server Shell

Connect your self-server and execute command on it via SSH

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Server Shell

uses: tzzs/server-shell@v1

Learn more about this action in tzzs/server-shell

Choose a version

server-shell

action-test

This action could connect your self-server and execute command on it via SSH. This is useful when you want to execute commands on your own server form your workflow.

Prerequisites

  • This action requires your own server SSH PRIVATE_KEY , IP and USERNAME corresponding to the PRIVATE_KEY.

Usage

Step 1: Set up your workflow.yml File

The SHELL parameter in with is the command that needs to be executed on your own server.

steps:
  - uses: actions/checkout@v2
  - run: npm install
    shell: bash
  - uses: ./
    with:
      PRIVATE_KEY: ${{ secrets.PRIVATE_KEY}}
      USERNAME: ${{secrets.USERNAME}}
      IP: ${{secrets.IP}}
      SHELL: |
        "echo action-test"
        "ls"

Step 2: Add repository secrets in the repository Settings/Secrets

Add the following parameters to secrets:

PRIVATE_KEY

IP

USERNAME

Input

The following parameters (some optional) need to be configured in workflow.

  1. PRIVATE_KEY [required]

This is from the ~/.ssh/id_rsa file.

  1. IP [required]
eg: 127.0.0.1
  1. USERNAME [required]
eg: root
  1. SHELL (optional), use the | symbol to add multiple commands
SHELL: |
	"echo action-test"
	"ls"

Output

The result of each command are printed in the action console.

Disclaimer

Protect your private key and use at your own risk.