My Learning Journey in CI/CD with Local IIS Server
Jawad Hayat
Posted on July 2, 2024
As a backend developer, I recently dived into the world of CI/CD while working with Angular. Here’s a quick overview of my process:
1. Create a Web API Project: Started with a new project and pushed the code to a GitHub repo.
2. Configure GitHub Actions: Set up the .NET build and test action by creating a workflow directory and a YAML file in .github
.
3. Set Up Self-Hosted Runner:
- Configured a new runner in GitHub Actions settings.
- Ran provided commands in PowerShell as an administrator to set up the runner locally.
- Verified the runner is working correctly in GitHub Actions settings. 4. Test the Configuration: Pushed changes to the master branch to ensure the jobs run successfully. 5. Install IIS Server: Created a website and bound it to a physical path on my PC. 6. Publish and Deploy Logic: Updated the YAML file for publishing and deploying to IIS.
Here’s the YAML script I used:
name: .NET
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build-and-deploy:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Publish
run: dotnet publish -c Debug -o dotnetcorewebapp .
- name: Stop IIS
run: iisreset /stop
- name: Deploy to IIS
run: Copy-Item -Path {Your Path}\* -Destination {Your Path} -Recurse -Force
- name: List files in IIS
run: Get-ChildItem -Path {Your Path} -Recurse
- name: Start IIS
run: iisreset /start
This journey has been a fantastic learning experience, enhancing my skills in automation and deployment. Looking forward to more such explorations!
💖 💪 🙅 🚩
Jawad Hayat
Posted on July 2, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.