CI/CD with GitHub Actions for Plesk Deployment Print

  • 0

Automating Deployments with GitHub Actions

Set up continuous deployment from GitHub to your Plesk Windows hosting using GitHub Actions.

Prerequisites

  • GitHub repository with your .NET project
  • FTP credentials from Plesk
  • GitHub repository secrets configured

Step 1: Get FTP Credentials from Plesk

  1. Log in to Plesk
  2. Go to Websites & Domains → your domain
  3. Click FTP Access
  4. Note your FTP host, username, and set a password

Step 2: Add GitHub Secrets

  1. Go to your GitHub repository
  2. Click SettingsSecrets and variablesActions
  3. Add these secrets:
    • FTP_SERVER - Your FTP hostname
    • FTP_USERNAME - Your FTP username
    • FTP_PASSWORD - Your FTP password

Step 3: Create Workflow File

Create .github/workflows/deploy.yml:

name: Deploy to Plesk

on:
  push:
    branches: [ main ]
  workflow_dispatch:

jobs:
  build-and-deploy:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v4

    - name: Setup .NET
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: '8.0.x'

    - name: Restore dependencies
      run: dotnet restore

    - name: Build
      run: dotnet build --configuration Release --no-restore

    - name: Test
      run: dotnet test --no-build --configuration Release

    - name: Publish
      run: dotnet publish -c Release -o ./publish

    - name: Deploy to FTP
      uses: SamKirkland/FTP-Deploy-Action@v4.3.4
      with:
        server: ${{ secrets.FTP_SERVER }}
        username: ${{ secrets.FTP_USERNAME }}
        password: ${{ secrets.FTP_PASSWORD }}
        local-dir: ./publish/
        server-dir: /httpdocs/

Step 4: Trigger Deployment

Deployments will automatically run when you:

  • Push to the main branch
  • Manually trigger via Actions tab

Advanced: Web Deploy Instead of FTP

For larger deployments, Web Deploy is faster. Use a custom script:

- name: Deploy via Web Deploy
  shell: cmd
  run: |
    msdeploy -verb:sync ^
      -source:contentPath="./publish" ^
      -dest:contentPath="YourSite",computerName="https://yourserver:8172/msdeploy.axd",username="${{ secrets.DEPLOY_USER }}",password="${{ secrets.DEPLOY_PASS }}",authtype="basic"

Best Practices

  • Always run tests before deployment
  • Use branch protection rules
  • Consider staging environment first
  • Monitor deployment logs
  • Set up deployment notifications

Was this answer helpful?

« Back