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
- Log in to Plesk
- Go to Websites & Domains → your domain
- Click FTP Access
- Note your FTP host, username, and set a password
Step 2: Add GitHub Secrets
- Go to your GitHub repository
- Click Settings → Secrets and variables → Actions
- Add these secrets:
FTP_SERVER- Your FTP hostnameFTP_USERNAME- Your FTP usernameFTP_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