Last active
June 5, 2023 21:44
-
-
Save richardwu/acbfcd68ae318e506347a87734e8a683 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
set -e | |
if [[ $# -ne 2 ]] ; then | |
echo "usage: $0 <GH org url eg https://github.com/tensor-hq> <GH runner token>" | |
exit 1 | |
fi | |
ORGURL="$1" | |
TOKEN="$2" | |
# Add other system deps here | |
# gcc = for cc + cargo installs | |
# Install lib1.1 for anchor (need security list) | |
echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list | |
sudo apt-get update | |
sudo apt install -y git gcc libssl1.1 bzip2 pkg-config make g++ libusb-1.0-0-dev libudev-dev | |
sudo rm -f /etc/apt/sources.list.d/focal-security.list | |
# Install docker | |
if [ ! $(getent group docker) ] ; then | |
sudo addgroup --system docker | |
sudo adduser ubuntu docker | |
newgrp docker | |
fi | |
sudo snap refresh snapd # sometimes stale | |
sudo snap install docker | |
echo "waiting 10s for docker..." | |
sleep 10 # wait for docker to start | |
sudo docker info | |
# Install npm/yarn | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash | |
. ~/.nvm/nvm.sh | |
nvm install 16 | |
npm install yarn -g | |
# Install rust | |
curl https://sh.rustup.rs -sSf | sh -s -- -y | |
source "$HOME/.cargo/env" | |
# Download the runner binary | |
mkdir -p actions-runner | |
cd actions-runner | |
curl -o actions-runner-linux-x64-2.294.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.294.0/actions-runner-linux-x64-2.294.0.tar.gz | |
echo "a19a09f4eda5716e5d48ba86b6b78fc014880c5619b9dba4a059eaf65e131780 actions-runner-linux-x64-2.294.0.tar.gz" | shasum -a 256 -c | |
tar xzf ./actions-runner-linux-x64-2.294.0.tar.gz | |
# Configure + start runner | |
./config.sh --url $ORGURL --token $TOKEN --unattended | |
sudo ./svc.sh install | |
sudo ./svc.sh start | |
# Set up cron tab to clean up docker images >1h old every 5 minute (adjust accordingly) | |
(crontab -l 2>/dev/null ; echo '*/5 * * * * docker system prune -af --filter "until=1h"') | crontab - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment