GitHub Actions allow you to run a series of actions on your code based on various triggers. This includes actions such as compiling the code or running unit tests. The actions are performed by a "runner" system. This system can either on be a virtual environment on the GitHub infrastructure or a locally hosted server.

Using a self-hosted runner

The common reasons to run a self-hosted runner is that you might want to use GitHub Actions, but are on a network that is firewalled off, you have software that might be easier to configure ahead of time, or have security concerns about information being used by the GitHub infrastructure.

Some tips

Popular Actions

These are actions that community members have reported finding useful.

Know a GitHub Action other community members would love?
Make a suggestion!

Some simple examples

Uses github provided windows runner to build a .Net web application and run test cases

Original file

name: build-and-test

on:
  workflow_dispatch:
  push:
    branches:
      - main
jobs:
  build:
    env:
      msbuild-path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin
      vstest-path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform

    runs-on: [windows-latest]
    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Restore Nuget Packages
        run: "\"$\\MSBuild.exe\" -t:restore -p:RestorePackagesConfig=true $\\exampleapp\\exampleapp.sln"
        shell: cmd

      - name: Build website
        run: "\"$\\MSBuild.exe\" $\\exampleapp\\exampleapp.sln"
        shell: cmd

      - name: Test
        run: "\"$\\vstest.console.exe\" /Platform:x64 $\\exampleapp\\exampleappTests\\bin\\Debug\\exampleappTests.dll"
        shell: cmd

Uses github provided windows runner to build a .Net application and calls PowerShell GitHub API library to upload a release zip of the binaries

Original file

name: create-release-zip

on:
  workflow_dispatch:
  release:
    types: [created]

jobs:
  build:
    env:
      msbuild-path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin
      vstest-path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform


    runs-on: [windows-latest]
    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Restore Nuget Packages
        run: "\"$\\MSBuild.exe\" -t:restore -p:RestorePackagesConfig=true -p:Configuration=Release $\\exampleapp\\exampleapp.sln"
        shell: cmd

      - name: Build website
        run: "\"$\\MSBuild.exe\" -p:Configuration=Release $\\exampleapp\\exampleapp.sln"
        shell: cmd

      - name: Test
        run: "\"$\\vstest.console.exe\" /Platform:x64 $\\exampleapp\\exampleappTests\\bin\\Release\\exampleappTests.dll"
        shell: cmd

      - name: Build and deploy to directory
        shell: cmd
        run: "\"$\\MSBuild.exe\" -p:Configuration=Release -p:PublishProfile=PubForZip -p:DeployOnBuild=true $\\exampleapp\\exampleapp\\exampleapp.csproj"


      - name: Debug file path issue
        run: |
          $exampleapps_dlls = (Get-ChildItem -Path $ -Recurse -force -ErrorAction SilentlyContinue -Include 'exampleapp.dll' )
          foreach( $dll in $exampleapp_dlls) { Write-Output ("::debug::DLL found at" + $dll.FullName) }
          $web_configs = (Get-ChildItem -Path $ -Recurse -force -ErrorAction SilentlyContinue -Include 'web.config' )
          foreach( $config in $web_configs) { Write-Output ("::debug::Web config found at " + $config.FullName) }

      - name: Compress Release directory
        run: Compress-Archive -Path $\exampleapp\exampleapp\bin\app.publish\* -DestinationPath $\exampleapp.zip

      - name: Install PowerShellForGitHub
        run: Install-Module -Name PowerShellForGitHub -Scope CurrentUser  -Repository PSGallery -Force

      - name: Add zip to release download
        run: |
          Set-GitHubConfiguration -SessionOnly -DefaultOwnerName UIUCLibrary
          Set-GitHubConfiguration -SessionOnly -DefaultRepositoryName winshib-exampleapp
          $secureString = ("$" | ConvertTo-SecureString -AsPlainText -Force)
          $cred = New-Object System.Management.Automation.PSCredential "username is ignored", $secureString
          Set-GitHubAuthentication -Credential $cred -SessionOnly
          $secureString = $null # clear this out now that it's no longer needed
          $cred = $null # clear this out now that it's no longer needed
          $tag = "$".Substring(10)
          Write-Output "::debug::$tag"
          $release_id = (Get-GitHubRelease -Tag $tag).ID
          New-GitHubReleaseAsset -Release $release_id -Path $\exampleapp.zip