Skip to content

Instantly share code, notes, and snippets.

@robert-clayton
Last active January 19, 2021 22:44
Show Gist options
  • Select an option

  • Save robert-clayton/cfb383c183203cbc0b21ecbee41936b2 to your computer and use it in GitHub Desktop.

Select an option

Save robert-clayton/cfb383c183203cbc0b21ecbee41936b2 to your computer and use it in GitHub Desktop.
Github Self-Hosted Runner Setup

Linux (Needs updating)

#!/bin/bash
# Set up a new ec2 instance with self-hosted github runner
###################
PAT=
GITHUB_USER=
GITHUB_REPO=
###################
sudo yum update -y
sudo yum install git jq -y
mkdir ~/actions-runner && cd ~/actions-runner
curl -O -L https://github.com/actions/runner/releases/download/v2.262.1/actions-runner-linux-x64-2.262.1.tar.gz
tar xzf ./actions-runner-linux-x64-2.262.1.tar.gz
TOKEN=$(curl -s -XPOST \
                -H "authorization: token $PAT" \
                https://api.github.com/repos/$GITHUB_USER/$GITHUB_REPO/actions/runners/registration-token |\
                jq -r .token)
./config.sh --url https://github.com/$GITHUB_USER/$GITHUB_REPO --token $TOKEN --name "my-runner-$(hostname)" --work _work
sudo ./svc.sh install
sudo ./svc.sh start
unset PAT GITHUB_USER GITHUB_REPO TOKEN
#!/bin/bash
# Teardown ec2 instance with self-hosted github runner
###################
PAT=<Super Secret>
GITHUB_USER=<User>
GITHUB_REPO=<Repo>
###################
cd ~/actions-runner
sudo ./svc.sh stop
sudo ./svc.sh uninstall
TOKEN=$(curl -s -XPOST \
                -H "authorization: token $PAT" \
                https://api.github.com/repos/$GITHUB_USER/$GITHUB_REPO/actions/runners/registration-token |\
                jq -r .token)
./config.sh remove --token $TOKEN
unset PAT GITHUB_USER GITHUB_REPO TOKEN

Windows (Up-to-date)

  • Run the following to grab dependencies
# Install Chocolatey - Also Grabs 7Zip
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'))

# Grab Dependencies via Chocolatey
choco install git.commandline --params "/GitAndUnixToolsOnPath" -y
choco install vcpython27 -y
choco install python2 -y
choco install python3 -y
choco install awscli -y
choco install jq -y
choco install visualstudio2019community -y
choco install epicgameslauncher -y

# Install python dependencies
py -2 -m pip install --upgrade pip
py -2 -m pip install pytest mock
git clone https://github.com/dskvr/ue4cli
cd ue4cli
git checkout feature/editor-plugin-support
py -3.7 setup.py install

# Grab runner repo
mkdir \actions-runner; cd \actions-runner
Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v2.275.1/actions-runner-win-x64-2.275.1.zip -OutFile actions-runner-win-x64-2.275.1.zip
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/actions-runner-win-x64-2.275.1.zip", "$PWD")

shutdown -r -t 0
  • After restart completes
    • log in to Epic Games Launcher
    • Install the necessary engine versions
    • Go to this link and download the plugin for the necessary engine versions
    • Extract plugin(s) to /UE_4.2X/Engine/Plugins/
  • Run the following to set up runner
###################
$Token = ''
$GithubUser = ''
$GithubRepo = ''
###################

# Get runner token
$Base64Token = [System.Convert]::ToBase64String([char[]]$Token);
$Headers = @{
    Authorization = 'Basic {0}' -f $Base64Token;
    };
$Response = Invoke-RestMethod -Headers $Headers -Uri "https://api.github.com/repos/$GithubUser/$GithubRepo/actions/runners/registration-token" -Method Post

# Start runner
# - Set name "windows-sh"
.\config.cmd --url "https://github.com/$GithubUser/$GithubRepo" --token $Response.token --name "my-runner-$(hostname)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment