Overview
The CI/CD pipeline automates:- Build: Compiling the application in Release mode
- Test: Running unit and functional tests
- Publish: Creating deployment artifacts
- Deploy: Deploying to hosting environment (SmarterASP.NET)
GitHub Actions Workflow
The project includes a pre-configured workflow at:Workflow Triggers
The pipeline runs automatically on:- Push to main/master: Deploys every commit to main branch
- Manual trigger: Via GitHub Actions UI (
workflow_dispatch)
Pipeline Stages
1. Checkout Code
Clones the repository to the runner:2. Setup .NET Environment
Installs .NET 8.0 SDK:3. Restore Dependencies
Restores NuGet packages:4. Build Application
Builds the solution in Release configuration:5. Run Tests
Executes all unit and functional tests:6. Publish Application
Creates deployment artifacts:7. Deploy via Web Deploy
Deploys to SmarterASP.NET using MSDeploy:Configuration
GitHub Secrets
Configure the following secrets in your GitHub repository: Settings → Secrets and variables → Actions → New repository secret| Secret Name | Description | Example |
|---|---|---|
SMARTERASP_PASSWORD | Your SmarterASP.NET password | your-password |
CONNECTION_STRING | Production database connection (optional) | Server=...;Database=... |
JWT_SECRET_KEY | Production JWT signing key (optional) | your-32-char-key |
Environment Variables
Define workflow-level environment variables:Complete Workflow Example
Here’s the full workflow file from the project:Enhanced Workflow with Testing
To add automated testing before deployment:FTP Deployment Alternative
If Web Deploy is not available, use FTP deployment:Using FTP-Deploy-Action
Required Secrets for FTP
FTP_SERVER:win8145.site4now.netFTP_USERNAME: Your hosting usernameFTP_PASSWORD: Your hosting password
Code Coverage Reports
Add code coverage to your pipeline:Multi-Environment Deployment
Deploy to different environments based on branch:Manual Approval Gates
Require manual approval for production deployments:- Go to Settings → Environments → New environment
- Create environment named
production - Enable Required reviewers
- Add reviewers who must approve deployments
Monitoring Pipeline Status
Workflow Badges
Add a status badge to your README:Notifications
Configure notifications for failed deployments:Rollback Strategy
Implement rollback capabilities:Troubleshooting
Pipeline Fails on Build
- Check .NET SDK version matches project requirements
- Verify all NuGet packages are restorable
- Review build logs for compilation errors
Pipeline Fails on Tests
- Ensure test projects have correct references
- Check for missing test dependencies
- Verify test database configuration
Pipeline Fails on Deploy
- Verify GitHub secrets are configured correctly
- Check publish profile settings
- Ensure hosting credentials are valid
- Review deployment logs in workflow output
Deployment Succeeds but Site Doesn’t Work
- Check
appsettings.Production.jsonconfiguration - Verify database connection string
- Review application logs in hosting panel
- Ensure database migrations were applied
Best Practices
- Test Before Deploy: Always run tests before deployment
- Use Secrets: Never hardcode credentials in workflow files
- Environment-Specific Configs: Use different settings per environment
- Implement Rollback: Have a strategy to revert failed deployments
- Monitor Deployments: Set up notifications for pipeline failures
- Version Tags: Tag releases for traceability
- Branch Protection: Require PR reviews before merging to main
- Staging Environment: Test in staging before production
Next Steps
- Configure deployment environments in GitHub
- Set up branch protection rules
- Implement semantic versioning with automated tagging
- Add deployment notifications to your team’s communication tool