Skip to content

Instantly share code, notes, and snippets.

@pgressa
Created July 12, 2021 09:15
Show Gist options
  • Save pgressa/63058f55432d432a4893ca47a94d30f7 to your computer and use it in GitHub Desktop.
Save pgressa/63058f55432d432a4893ca47a94d30f7 to your computer and use it in GitHub Desktop.
Install self-hosted runners
#!/usr/bin/env bash
REPOSITORY_URL=$1
TOKEN=$2
RUNNER_ID=1000
RUNNER_DIR_NAME=
for i in {0..1000}; do
RUNNER_DIR_NAME=runner_$i
echo "Checking $RUNNER_DIR_NAME"
if [[ -d "runner_$i" ]]; then
echo "Runner $i exists"
else
echo "Found runner $i"
RUNNER_ID=$i
break
fi
done
mkdir $RUNNER_DIR_NAME
pushd $RUNNER_DIR_NAME
curl -o actions-runner-linux-x64-2.277.1.tar.gz -L https://github.com/actions/runner/releases/download/v2.277.1/actions-runner-linux-x64-2.277.1.tar.gz
tar xzf ./actions-runner-linux-x64-2.277.1.tar.gz
./config.sh --unattended --name "$(hostname)_${RUNNER_DIR_NAME}" --url $REPOSITORY_URL --token $TOKEN
sudo ./svc.sh install
sudo ./svc.sh start
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment