This repository contains scripts to install and uninstall a self-hosted GitHub Actions Runner on an Ubuntu server.
setup_runner.sh: Sets up and configures the GitHub Actions Runner as a service on the system.uninstall_runner.sh: Stops, uninstalls, and deregisters the GitHub Actions Runner from GitHub, then cleans up files.config.sh: Configuration file containing variables needed by both setup and uninstall scripts.
- Ubuntu server.
jqinstalled for parsing JSON responses.- A GitHub Personal Access Token (PAT) with permissions to manage Actions Runners in your organization.
-
Clone the Repository
git clone https://github.com/your-username/your-repo.git cd your-repo -
Edit the Configuration File
Open
runner_config.shand set your GitHub organization, PAT, and other configurations:# runner_config.sh GITHUB_ORGANIZATION="your_organization" GITHUB_PAT="your_personal_access_token" RUNNER_VERSION="2.320.0" RUNNER_DIR="/home/ubuntu/actions-runner" -
Run the Setup Script
Execute the
setup_runner.shscript to set up the GitHub Actions Runner:./setup_runner.shThis script will:
- Create the necessary directory.
- Download, extract, and configure the GitHub Actions Runner.
- Install and start the runner as a service.
To fully remove the GitHub Actions Runner, deregister it from GitHub, and clean up all associated files, run the uninstall_runner.sh script:
./uninstall_runner.sh
This script will:
- Stop and uninstall the runner service.
- Remove the runner from GitHub.
- Delete the runner directory from the server.
- Do not run these scripts with
sudo;sudois used internally as needed. - Ensure the GitHub PAT in
runner_config.shhas sufficient permissions to create and remove runners (repo, admin:org). """