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 Settings → Secrets and variables → Actions
  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/[email protected]
      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://awh-plesk1-win2022.adaptivewebhosting.com:8172/msdeploy.axd?site=YourSite",username="${{ secrets.DEPLOY_USER }}",password="${{ secrets.DEPLOY_PASS }}",authtype="basic"

Replace YourSite with your domain name as it appears in Plesk (the IIS site name), and save the Web Deploy user name and password from the Plesk Web Deploy Publishing Settings as the DEPLOY_USER and DEPLOY_PASS secrets. The server's certificate is publicly trusted for awh-plesk1-win2022.adaptivewebhosting.com, so -allowUntrusted is not needed; add it only if you connect by IP address or another name.

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