Last active
October 7, 2022 16:13
-
-
Save richardwu/6ec3562e482941f51c19b54b4a1997d5 to your computer and use it in GitHub Desktop.
Simple script to install + run an GH org runner on an AWS EC2 instance.
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 | |
# perl-Digest-SHA = for shasum below | |
# gcc = for cc + cargo installs | |
# openssl-devel = some cargo packages need it (anchor) | |
sudo yum install -y tmux perl-Digest-SHA htop git gcc openssl-devel | |
# Install docker | |
sudo amazon-linux-extras install docker -y | |
sudo usermod -a -G docker ec2-user | |
sudo systemctl enable docker | |
sudo systemctl start docker | |
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 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 ; 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