Streamlining IIS Deployments with Self-Hosted Runners: A Boost to Engineering Productivity Metrics

In the fast-paced world of software development, optimizing deployment workflows is crucial for maintaining high engineering productivity metrics. Automating routine tasks, especially those involving on-premise infrastructure, can significantly reduce manual effort and potential errors. A recent discussion on the GitHub Community forum highlighted a common challenge: how to precisely control IIS websites during a deployment using GitHub Actions.

Developer optimizing deployment workflow on a computer with server racks in the background.
Developer optimizing deployment workflow on a computer with server racks in the background.

The Challenge: Granular IIS Control in GitHub Workflows

A developer, Rod-at-DOH, was looking for a GitHub Marketplace action to manage specific IIS websites on an internal, on-premise server. Their setup involved a GitHub Self-Hosted Runner on the same server, and the goal was to deploy a website to IIS on another internal server. The workflow needed to:

  • Stop a single website on the target IIS server.
  • Allow the workflow to deploy new files.
  • Restart only that specific website.

Rod-at-DOH initially considered the iis-service-action but quickly realized it would stop the entire IIS service, which was unacceptable as the server hosted multiple critical websites. The core question was: Is there a GitHub Action that offers this level of granular control?

Robotic arm precisely stopping and starting a single website on a server rack, symbolizing granular IIS control.
Robotic arm precisely stopping and starting a single website on a server rack, symbolizing granular IIS control.

The Community Solution: Direct PowerShell for Precision

The insightful reply from xalonious provided a practical and efficient solution: leverage direct PowerShell commands within the GitHub Workflow, eliminating the need for a specific Marketplace action. This approach is particularly effective when the workflow is running on a self-hosted runner located on the same Windows server that hosts IIS.

The key insight is that a self-hosted runner, running on a Windows machine, can execute PowerShell scripts directly. These scripts can then interact with the local IIS installation, provided the Windows account running the self-hosted runner has the necessary permissions to manage IIS sites and application pools. This method offers surgical precision, allowing developers to target only the required website or application pool without affecting others.

Here’s the elegant PowerShell snippet shared by xalonious:

jobs:
  deploy:
    runs-on: self-hosted
    steps:
      - name: Stop IIS website
        shell: powershell
        run: |
          Import-Module WebAdministration
          Stop-Website -Name "YourSiteName"
          # deploy/copy files here
      - name: Start IIS website
        shell: powershell
        run: |
          Import-Module WebAdministration
          Start-Website -Name "YourSiteName"

This simple yet powerful approach demonstrates how to:

  • Use Import-Module WebAdministration to access IIS management cmdlets.
  • Execute Stop-Website -Name "YourSiteName" to halt a specific site.
  • Execute Start-Website -Name "YourSiteName" to restart it after deployment.

Enhancing Engineering Productivity Metrics with Smart Automation

This community insight underscores a vital principle in DevOps: sometimes the most effective solutions are not found in pre-packaged actions but in directly utilizing the underlying capabilities of your infrastructure. By embedding PowerShell commands directly into your GitHub Workflow, you gain fine-grained control over your deployments, reduce dependencies on external Marketplace actions, and ensure greater stability for multi-site servers.

Implementing such precise deployment steps directly contributes to improved engineering productivity metrics. Developers can deploy updates faster and with higher confidence, minimizing downtime and the risk of impacting unrelated services. While this specific solution focuses on IIS, the principle extends to other self-hosted runner scenarios where direct scripting can unlock powerful automation. Keeping an eye on your GitHub dashboard will show the efficiency gains from these streamlined workflows.

This discussion serves as a powerful reminder that the GitHub community is a rich resource for practical, real-world solutions that can significantly enhance your development and deployment strategies.

|

Dashboards, alerts, and review-ready summaries built on your GitHub activity.

 Install GitHub App to Start
Dashboard with engineering activity trends