Skip to content

Instantly share code, notes, and snippets.

@patrickhulce
Last active September 11, 2024 15:06
Show Gist options
  • Save patrickhulce/5035d49e7d86277fa73cab1350ba9928 to your computer and use it in GitHub Desktop.
Save patrickhulce/5035d49e7d86277fa73cab1350ba9928 to your computer and use it in GitHub Desktop.
GitHub Self-Hosted Runners
#!/bin/bash
# Non-scripted Tasks:
# - Configure device name in Preferences > Sharing
# - Enable Remote Login & Remote Management in Preferences > Sharing
# - Enable automatic login/disable password after sleep in Preferences > Security & Privacy > General
# - Disable screensaver/sleep in Preferences > Energy Saver
# - Disable spotlight indexing of home directory
# - Add a runner in GitHub UI to grab your token https://github.com/<org>/<repo>/settings/actions/runners/new
# If M1 enable Rosetta
softwareupdate --install-rosetta
# Disable spotlight indexing service
sudo mdutil -a -i off
# Install homebrew, this should also prompt to install XCode
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# Install extra taps
brew tap homebrew/cask
brew tap homebrew/cask-versions
brew tap homebrew/services
# Install utilities
brew update
brew install git git-lfs hub
brew install --cask docker google-chrome firefox microsoft-edge
git lfs install
# Install nvm (see https://github.com/nvm-sh/nvm#installing-and-updating)
touch ~/.zshrc
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
# Setup npm packages
nvm install v14
npm install -g yarn
# Setup GitHub runner
mkdir actions-runner && cd actions-runner
curl -O -L https://github.com/actions/runner/releases/download/v2.287.1/actions-runner-osx-x64-2.287.1.tar.gz
tar xzf ./actions-runner-osx-x64-2.287.1.tar.gz
./config.sh --url https://github.com/XXXXX/XXXXX --token XXXX
./svc.sh install
./svc.sh start
# Non-scripted tasks:
# - Control Panel > System and Security > System > See the name of this computer > Change...
# - Control Panel > System and Security > System > Allow remote access > Allow remote connections to this computer
# - Control Panel > System and Security > Power Options > High performance > Edit Plan Settings > "Never"/"Never"
# - Windows+R > netplwiz > Uncheck "Users must enter a user name and password..." > Apply
# - [tigervnc] Programs > TigerVNC 64-bit > VNC Server (Service Mode) > Security > Configure
# - [tigervnc] Control Panel > Firewall > Advanced Settings > Add Inbound Rule > Allow 5900-5910
# - [tigervnc] Programs > TigerVNC 64-bit > VNC Server (Service Mode) > Start VNC Service
# Install chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install -y git git-lfs zip hub nvm nano visualstudio2019community
Add-Content $profile '$env:Path += ";C:\Program Files\Git\usr\bin"' # add git tools to your default path
# In git bash or reloaded powershell
git lfs install
nvm install 10.21.0
nvm use 10.21.0
npm install -g yarn jest
# Setup github actions runner
cd \
mkdir actions-runner; cd actions-runner
Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v2.287.1/actions-runner-win-x64-2.287.1.zip -OutFile actions-runner-win-x64-2.287.1.zip
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/actions-runner-win-x64-2.287.1.zip", "$PWD")
./config.cmd --url https://github.com/XXXXX/XXXXX --token XXXX # Answer Y to do you want to configure as a service, use the user account you setup to automatically login
Get-Service "actions.runner.*"
Set-ExecutionPolicy RemoteSigned # allow github actions to execute powershell commands as part of github actions
# Download Google Cloud SDK from
# Disable "app execution aliases" in settings like https://stackoverflow.com/a/57168165/1091925 says
# Install python
gcloud init
choco install python
# Logout of RDP and relogin user
qwinsta # find your current session ID and use it instead of 0 in next command
tscon 0 /dest:console
@dunklesToast
Copy link

Thanks for the scripts!

Two minor things:

  1. The latest GitHub Runner Version is now 2.287.1 - the script works flawless with that so you might want to update the URL
  2. The URL to add a runner changed. It's now https://github.com/<org>/<repo>/settings/actions/runners/new

@patrickhulce
Copy link
Author

Awesome thank you so much for contributing back @dunklesToast! Updated 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment