Skip to content

A GitHub Action to deploy current GitHub repository to a server using SSH protocol.

License

Notifications You must be signed in to change notification settings

Rxinui/ssh-deploy-repo-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SSH Deploy GitHub Repo Action

Originally created by @pitscher and forked by @Rxinui

Simple and fast GitHub Action that deploys your current project to your server using SSH protocol (ie. OVH vps server).

It deploys a single branch when cloning GitHub repo which make the deployment faster (see target-branch).

Requirements

  • Server where SSH is supported
  • Server with bash, git installed.
  • User with SSH access granted
  • Access granted to project's git repository. It will be deployed by using git clone

Actions parameters

Parameters Required Description Values
ssh-user x SSH login username Any
ssh-password x SSH login password. Favouring the use of GitHub secrets Any
ssh-domain x SSH login domain. Favouring the use of GitHub secrets Any
git-clone-by Git repository clone method. Value must be lowercase. Defaults to https ssh, https
target-branch Git branch to clone/checkout. Defaults to main Any
target-directory Path where git repository will be cloned. Defaults to ~/ Any
pre-command Command lines to execute before the deployment. If pre-command failed, then deployment and post-command won't be executed. Any
post-command Command lines to execute after the deployment within the target-directory. If pre-command or deployment failed, then post-command won't be executed. Any

Example usage

For instance, within .github/workflows/main.yml

Basic usage

Requires version >= v1

name: Deployment of current GitHub repo on a server through SSH
on:
  push:
    branches: [main, develop]
jobs:
  deploy:
    runs-on: ubuntu-20.04
    steps:
      - uses: Rxinui/ssh-deploy-repo-action@v1
        with:
          # Required
          ssh-user: myuser
          ssh-password: ${{ secrets.OVH_HOSTING_PASSWORD }}
          ssh-domain: ${{ secrets.OVH_HOSTING_DOMAIN }}
          # Optional
          git-clone-by: ssh
          target-branch: develop
          target-directory: /opt/my-awesome-project/

Advanced usage : define post and pre deployment command

Requires version >= v1.1

name: Deployment of current GitHub repo and use of docker-compose on a server through SSH
on:
  push:
    branches: [main, develop]
jobs:
  deploy:
    runs-on: ubuntu-20.04
    steps:
      - uses: Rxinui/ssh-deploy-repo-action@v1.1
        with:
          # Required
          ssh-user: myuser
          ssh-password: ${{ secrets.OVH_HOSTING_PASSWORD }}
          ssh-domain: ${{ secrets.OVH_HOSTING_DOMAIN }}
          # Optional
          git-clone-by: ssh
          target-branch: develop
          target-directory: /opt/my-awesome-project/
          pre-command: | # multi-line script possible
            cd $TARGET_DIRECTORY && 
            docker-compose down -v --remove-orphans
          post-command: docker-compose up -d -V --force-recreate

About

A GitHub Action to deploy current GitHub repository to a server using SSH protocol.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 94.0%
  • Dockerfile 6.0%