🚀 pos-api CI/CD Pipeline — GitHub Actions to MonsterASP.Net

Automated deploy: push to master → build → test → publish → FTP deploy


📋 Overview

ItemDetail
Repogithub.com/christianj27/pos-api
Framework.NET 10 (ASP.NET Core Web API)
DatabasePostgreSQL (Npgsql + EF Core)
HostingMonsterASP.Net shared hosting
Deploy methodFTP via GitHub Actions

🔧 Prerequisites

1. GitHub Secrets

Add these in repo → Settings → Secrets and variables → Actions:

SecretValue
FTP_HOSTsite80268.siteasp.net
FTP_USERNAMEsite80268
FTP_PASSWORD(from MonsterASP control panel)

2. MonsterASP.Net — Environment Variables

Set these in the MonsterASP control panel → Environment Variables / App Settings:

VariableValue
ASPNETCORE_ENVIRONMENTProduction
ConnectionStrings__DefaultConnection(MonsterASP PostgreSQL connection string)
Jwt__SecretKey(32+ char random secret)

Note: Use double underscore __ for nested keys — .NET maps ConnectionStrings__DefaultConnection to ConnectionStrings:DefaultConnection automatically.


📄 Workflow File

Create .github/workflows/deploy.yml in the repo root:

name: Deploy pos-api to MonsterASP.Net
 
on:
  push:
    branches: [master]
 
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v4
 
      - name: Setup .NET 10
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '10.x'
 
      - name: Restore
        run: dotnet restore Pos.slnx
 
      - name: Build
        run: dotnet build Pos.slnx --configuration Release --no-restore
 
      - name: Run tests
        run: dotnet test Pos.Test/Pos.Test.csproj --configuration Release --no-build
 
      - name: Publish
        run: dotnet publish Pos.Api/Pos.Api.csproj --configuration Release --no-build -o ./publish
 
      - name: Deploy to MonsterASP.Net via FTP
        uses: SamKirkland/[email protected]
        with:
          server: ${{ secrets.FTP_HOST }}
          username: ${{ secrets.FTP_USERNAME }}
          password: ${{ secrets.FTP_PASSWORD }}
          local-dir: ./publish/
          server-dir: /wwwroot/

🏃 Pipeline Stages

#StageDescription
1CheckoutPulls latest code from master
2Setup .NETInstalls .NET SDK 10.x on the runner
3RestoreDownloads NuGet dependencies (dotnet restore)
4BuildCompiles in Release mode (dotnet build)
5TestRuns xUnit tests with in-memory DB
6PublishOutputs deployable files to ./publish/
7FTP DeployUploads everything to /wwwroot/ on MonsterASP

🐛 Troubleshooting

Error: getaddrinfo ENOTFOUND

Cause: FTP_HOST secret is missing, empty, or has wrong value.
Fix: Check GitHub Secrets → FTP_HOST should be site80268.siteasp.net (no ftp:// prefix, no port).

Error: 500.30 — ASP.NET Core app failed to start

Cause: Missing or wrong environment variables on the server.
Fix: Set the MonsterASP environment variables listed above — especially ConnectionStrings__DefaultConnection and Jwt__SecretKey.

Error: HTTP 502 / 503

Cause: App pool crashed or DB connection failed.
Fix: Check MonsterASP event logs or temporarily enable stdout logging in web.config.