Auto Deploy Using Github Action

Simple script to deploy branch to a server

Auto Deploy Using Github Action
Photo by Lala Azizli / Unsplash

Script

name: Push staging branch to server

on:
  push:
    branches:
      - staging

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Push to server
        uses: appleboy/scp-action@v0.1.7
        with:
          host: server_ip
          username: server_username
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          passphrase: ${{ secrets.PASSPHRASE }}
          source: ./
          target: /target/folder

Set Variables

variables used in the script shall be set via Github dashboard:
repository/settings/secrets/actions

Action States

Action states may be viewed via the Actions tab in your repository
repository/actions