CD Pipeline with GitHub Actions

My implementation of CD workflow

This CD workflow setup doesn't have any triggers and I run it manually whenever I need to deploy a new version to the production. There is one job which takes care of publishing the project with two steps:

  • Check out step which prepearse the repository so it can be used in the next steps.
  • Publish step which compiles the .NET app in release mode and puts the output files into a folder.


name: Deploy Portfolio

on:
  workflow_dispatch:

jobs:
  publish:
    runs-on: ubuntu-latest
      
    steps:
    - uses: actions/checkout@v4
    - name: Setup .NET 8
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: 8.0.x
    
    - name: Publish .NET App
      run: |
          dotnet publish -c Release -o ${{ vars.PUBLISH_FOLDER_NAME }}
                            

The next step is to take the published .NET app and copy the files from GitHub to my server using SCP (Secure Copy Protocol) over SSH. To do this a few parameters need to be specified such as Host Name or SSH Private Key. In my case, I store all of them on GitHub repository's secrets.


    - name: Copy Files via SSH
         uses: appleboy/scp-action@v0.1.7
         with:
             host: ${{ secrets.DROPLET_HOST }}
             username: ${{ secrets.DROPLET_USER }}
             key: ${{ secrets.SSH_PRIVATE_KEY }}
             source: "${{ vars.PUBLISH_FOLDER_NAME }}/"
             target: "${{ vars.APP_DIRECTORY }}${{ vars.APP_NAME }}"
                            
An unhandled error has occurred. Reload 🗙