self-hosted-runners-playground
Programmatically create a self-hosted runner
# Get the tarball URL
curl --request GET \
--url https://api.github.com/repos/swinton/self-hosted-runners-playground/actions/runners/downloads \
--header ' accept: application/vnd.github.jane-hopper-preview+json,application/vnd.github.machine-man-preview+json' \
--header ' authorization: Bearer $TOKEN'
# Download the tarball
curl -O -L $TARBALL
# Extract the installer
tar xzf ./actions-runner-osx-x64-2.165.2.tar.gz
# Generate a registration token
curl --request POST \
--url https://api.github.com/repos/swinton/self-hosted-runners-playground/actions/runners/registration-token \
--header ' accept: application/vnd.github.jane-hopper-preview+json,application/vnd.github.machine-man-preview+json' \
--header ' authorization: Bearer $TOKEN'
# Create the runner and start the configuration experience
./config.sh --url https://github.com/swinton/self-hosted-runners-playground --token $REGISTRATION_TOKEN
# Create a remove token
curl --request POST \
--url https://api.github.com/repos/swinton/self-hosted-runners-playground/actions/runners/remove-token \
--header ' accept: application/vnd.github.jane-hopper-preview+json,application/vnd.github.machine-man-preview+json' \
--header ' authorization: Bearer $TOKEN'
./config.sh remove --token $REMOVAL_TOKEN
# OPTIONAL: Force-remove the self-hosted runner
curl --request DELETE \
--url https://api.github.com/repos/swinton/self-hosted-runners-playground/actions/runners/2 \
--header ' accept: application/vnd.github.jane-hopper-preview+json,application/vnd.github.machine-man-preview+json' \
--header ' authorization: Bearer $TOKEN'