{"id":2148,"date":"2025-12-19T20:29:34","date_gmt":"2025-12-19T20:29:34","guid":{"rendered":"https:\/\/blog.eu.enginyr.ing\/?p=2148"},"modified":"2025-12-19T20:30:18","modified_gmt":"2025-12-19T20:30:18","slug":"stop-paying-per-minute-for-github-actions-how-to-host-your-own-ci-cd-runners-on-a-e5-vps","status":"publish","type":"post","link":"https:\/\/www.serverspan.com\/en\/blog\/stop-paying-per-minute-for-github-actions-how-to-host-your-own-ci-cd-runners-on-a-e5-vps\/","title":{"rendered":"Stop Paying per Minute for GitHub Actions: How to Host Your Own CI\/CD Runners on a \u20ac5 VPS"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">If you are a developer or a team lead managing a growing codebase, you have likely hit &#8220;The Wall.&#8221; It usually arrives in the third week of the month as a polite but alarming email from GitHub: <em>&#8220;You have used 80% of your included Actions minutes.&#8221;<\/em> A few days later, your pipelines stop, or your credit card gets hit with unpredictable overage charges. GitHub Actions is an incredible tool that has revolutionized CI\/CD integration, but its billing model\u2014charging per minute of compute time\u2014effectively penalizes success. The more you code, test, and deploy, the more you pay.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For bootstrapped startups, agencies, and active open-source maintainers, this &#8220;success tax&#8221; can become a significant line item. But there is a better way. GitHub allows you to attach your own infrastructure to their CI\/CD platform. By replacing their &#8220;per-minute&#8221; shared runners with a &#8220;flat-rate&#8221; Virtual Private Server (VPS), you can slash your CI\/CD costs by over 90% while simultaneously boosting build speeds and gaining granular control over your build environment. In this comprehensive guide, we will walk you through setting up a production-ready self-hosted runner on a standard Linux VPS, turning a \u20ac5\/month server into a 24\/7 build workhorse that never charges you overtime.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Economics: Shared Runners vs. Self-Hosted Infrastructure<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To understand the value proposition, we must first dissect the pricing model. A standard GitHub Free account includes 2,000 automation minutes per month. For a solo developer pushing to a single repository, this is often sufficient. However, for a team of three developers pushing code daily, running unit tests, linting, and building Docker images, those minutes vanish quickly. Once you exceed that limit, or if you need the parallelization features of a Team plan, costs accrue rapidly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">GitHub charges approximately <strong>$0.008 per minute<\/strong> for a standard Linux runner (2 vCPU, 7GB RAM). That sounds negligible until you run the math for an active project:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>10 hours of extra build time:<\/strong> ~$4.80<\/li>\n<li><strong>100 hours of extra build time:<\/strong> ~$48.00<\/li>\n<li><strong>500 hours of extra build time:<\/strong> ~$240.00<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Now, compare this to the economics of a Virtual Private Server. An entry-level <a href=\"https:\/\/www.enginyring.com\/en\/virtual-servers\">ENGINYRING VPS<\/a> with similar or better specifications (high-frequency NVMe storage, dedicated RAM) costs a flat monthly fee roughly equivalent to just 10-12 hours of overage charges on the cloud. More importantly, a VPS is online 24 hours a day, 7 days a week. That is roughly <strong>43,800 minutes<\/strong> of potential build time per month\u2014for the same flat fee.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From a CFO\u2019s perspective, the choice is obvious: unpredictable variable costs vs. low, fixed operational costs. From a CTO\u2019s perspective, it means your developers never have to hesitate before triggering a build.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Performance Advantage: Why Persistence is Key<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Cost isn&#8217;t the only factor; in modern DevOps, speed is arguably more critical. Waiting 20 minutes for a pipeline to fail breaks the developer&#8217;s &#8220;flow state.&#8221; GitHub-hosted runners are &#8220;ephemeral.&#8221; This means every time you trigger a pipeline, GitHub spins up a fresh, empty virtual machine. It has to download your repository, install your dependencies (<code>npm install<\/code>, <code>pip install<\/code>, <code>cargo build<\/code>), and pull your Docker images from scratch.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A self-hosted runner is &#8220;persistent.&#8221; The files from the previous run are still there on the disk. This persistence unlocks massive performance gains:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Incremental Builds:<\/strong> If you use compiled languages like C++, Go, or Rust, a self-hosted runner doesn&#8217;t need to recompile the entire project if you only changed one file. It can use the existing object files.<\/li>\n<li><strong>Dependency Caching:<\/strong> That massive <code>node_modules<\/code> or <code>vendor<\/code> folder? It is already on the disk. <code>npm install<\/code> checks it and finishes in seconds rather than minutes. You don&#8217;t need to upload and download gigabytes of cache artifacts to GitHub&#8217;s storage.<\/li>\n<li><strong>Docker Layer Caching:<\/strong> This is the biggest win for containerized workflows. Base images (like Ubuntu, Node, or Python) remain locally cached. When your Dockerfile executes, it hits the local cache immediately instead of pulling layers from Docker Hub every single time.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In our experience managing development infrastructure for clients, we&#8217;ve seen build times drop from 15 minutes to under 3 minutes simply by moving to a self-hosted NVMe-powered VPS. That time savings translates directly to faster feature delivery.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Architecture: How Self-Hosted Runners Communicate<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before we dive into the installation, it helps to understand how the runner talks to GitHub. Many sysadmins worry about firewall complexity, but the architecture is surprisingly firewall-friendly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The self-hosted runner application creates a <strong>long-polling HTTPS connection<\/strong> to GitHub. It opens a connection <em>outbound<\/em> from your VPS to GitHub&#8217;s servers and waits for a job to be assigned. This means:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You <strong>do not<\/strong> need to open any inbound ports (like port 80 or 443) on your firewall.<\/li>\n<li>You <strong>do not<\/strong> need a static public IP address (though it helps for whitelisting).<\/li>\n<li>You <strong>do not<\/strong> need to configure complex NAT traversal or VPNs.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">As long as your VPS can reach <code>github.com<\/code> and <code>api.github.com<\/code> via HTTPS (port 443), the runner will work. This makes it incredibly secure by default, as the server effectively remains &#8220;dark&#8221; to inbound internet scans while still functioning as a CI node.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step-by-Step Guide: Setting Up Your Runner<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We will configure a <strong>Debian 12 (Bookworm)<\/strong> or <strong>Ubuntu 24.04<\/strong> VPS to act as a GitHub Actions runner. We assume you have SSH access to your server and root privileges.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Prepare the System and Dependencies<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Start by ensuring your system is up to date. A stale system can lead to weird dependency conflicts later on.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update && sudo apt upgrade -y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">GitHub&#8217;s runner application is built on .NET Core, so it requires a specific set of libraries to function. Install <code>curl<\/code> for downloading files, <code>tar<\/code> for extraction, and the required libraries:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y curl tar jq libdigest-sha-perl libicu-dev git<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Create a Dedicated User (Security Mandatory)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Security Warning:<\/strong> Never, under any circumstances, run the CI\/CD agent as <code>root<\/code>. If a malicious script (or even a poorly written one) runs in your pipeline, you do not want it having administrative privileges on your server. We will create a dedicated user named <code>runner<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo useradd -m -s \/bin\/bash runner<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If your workflows need to build Docker images, you must add this user to the docker group. Note that adding a user to the docker group is practically equivalent to root access, so treat this user securely.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Install Docker first if you haven't\ncurl -fsSL https:\/\/get.docker.com -o get-docker.sh\nsudo sh get-docker.sh\n\n# Add permission\nsudo usermod -aG docker runner<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, switch to the runner user to continue the installation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo su - runner<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Download the Runner Software<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to your GitHub repository (or Organization settings if you want a shared runner for multiple repos). Go to <strong>Settings > Actions > Runners<\/strong>, and click the green <strong>New self-hosted runner<\/strong> button.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Select &#8220;Linux&#8221; and &#8220;x64&#8221;. GitHub will generate a specific set of commands tailored to the latest version. It will look something like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Create a folder\nmkdir actions-runner && cd actions-runner\n\n# Download the latest runner package\n# (Note: The version number changes frequently; use the link GitHub provides)\ncurl -o actions-runner-linux-x64-2.311.0.tar.gz -L https:\/\/github.com\/actions\/runner\/releases\/download\/v2.311.0\/actions-runner-linux-x64-2.311.0.tar.gz\n\n# Extract the installer\ntar xzf .\/actions-runner-linux-x64-2.311.0.tar.gz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. Configure and Link<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run the configuration script. You will need the token provided on the GitHub setup page. Be aware that this token expires after one hour, so if you took a lunch break, refresh the page to get a new one.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/config.sh --url https:\/\/github.com\/YourOrg\/YourRepo --token YOUR_TOKEN_HERE<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">During configuration, you will be asked a few questions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Name of runner group:<\/strong> Press Enter for Default.<\/li>\n<li><strong>Name of runner:<\/strong> Give it a descriptive name like <code>vps-build-01-prod<\/code>.<\/li>\n<li><strong>Labels:<\/strong> This is crucial. Labels allow you to target this specific runner in your YAML files. We recommend adding labels like <code>self-hosted<\/code>, <code>linux<\/code>, and <code>high-perf<\/code>.<\/li>\n<li><strong>Work folder:<\/strong> Press Enter for <code>_work<\/code>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">5. Install as a System Service (Critical)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You could run the runner manually with <code>.\/run.sh<\/code>, but it will die the moment you close your SSH terminal. For production, we need it to run in the background and restart automatically if the server reboots.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">GitHub provides a helper script to install it as a <code>systemd<\/code> service. You must exit the <code>runner<\/code> user shell and return to your <code>sudo<\/code> user to run this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Exit 'runner' user session\nexit\n\n# Navigate to the folder\ncd \/home\/runner\/actions-runner\n\n# Install and start the service\nsudo .\/svc.sh install runner\nsudo .\/svc.sh start\n\n# Verify status\nsudo .\/svc.sh status<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If successful, you will see a status message indicating the service is <code>active (running)<\/code>. Go back to your GitHub Settings page; the runner should now show &#8220;Idle&#8221; with a green dot, ready to accept jobs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Critical Security Warning: The &#8220;Public Repo&#8221; Risk<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There is one golden rule for self-hosted runners that we cannot stress enough: <strong>Never attach a self-hosted runner to a public repository without strict controls.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the attack vector: On a public repository, anyone on the internet can fork your code. They can modify the CI configuration file (<code>.github\/workflows\/main.yml<\/code>) to run a malicious script\u2014say, a Bitcoin miner or a network scanner. Then, they submit a Pull Request (PR) to your repo.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If your runner is configured to build PRs automatically (which is the default behavior), it will execute that stranger&#8217;s malicious code directly on your VPS. They effectively have shell access to your server. They can steal environment variables, scan your internal network, or use your server for DDoS attacks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How to Mitigate:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Private Repositories:<\/strong> For private repos, the risk is minimal because only your trusted team members can push code.<\/li>\n<li><strong>Require Approval:<\/strong> If you must use it on a public repo, go to <strong>Settings > Actions > General<\/strong> and select <strong>&#8220;Require approval for all outside collaborators&#8221;<\/strong>. This ensures no workflow runs until a maintainer manually clicks &#8220;Approve and Run.&#8221;<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Maintenance: Keeping the Engine Clean<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Unlike GitHub&#8217;s ephemeral runners which vanish after use, your VPS accumulates digital trash. Every Docker build leaves behind layers; every <code>npm install<\/code> leaves cache files. If ignored, your disk will fill up, causing builds to fail with &#8220;No space left on device.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We recommend setting up a &#8220;Janitor&#8221; cron job. As the root user, setup a weekly cleaning schedule:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Open crontab\nsudo crontab -e\n\n# Add this line to prune unused images\/containers every Sunday at 4 AM\n0 4 * * 0 \/usr\/bin\/docker system prune -af --volumes > \/dev\/null 2>&1\n\n# Optional: Clean the runner's work directory (use with caution)\n# 0 5 * * 0 rm -rf \/home\/runner\/actions-runner\/_work\/*<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Advanced Configuration: Swap Space for Stability<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Compilers (like GCC, Rustc, or Webpack) are memory hungry. If you are using a smaller VPS (e.g., 2GB or 4GB RAM), a heavy build might trigger the Linux OOM (Out of Memory) Killer, which will unceremoniously kill your runner process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To prevent this, ensure you have a swap file configured. This acts as an overflow buffer for RAM.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Check for existing swap\nsudo swapon --show\n\n# If empty, create a 4GB swap file\nsudo fallocate -l 4G \/swapfile\nsudo chmod 600 \/swapfile\nsudo mkswap \/swapfile\nsudo swapon \/swapfile\n\n# Make it permanent\necho '\/swapfile none swap sw 0 0' | sudo tee -a \/etc\/fstab<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">When to Make the Switch<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Self-hosting isn&#8217;t for everyone. It adds an operational layer to your stack. So, should you switch today? Here is our decision matrix:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Hobbyist (0-10 hours\/month):<\/strong> Stick with GitHub Free. It is zero maintenance and free.<\/li>\n<li><strong>Small Team (10-50 hours\/month):<\/strong> You are likely hitting limits or experiencing slow builds. A single VPS will speed up your workflow significantly and cap your costs.<\/li>\n<li><strong>Power Users \/ Enterprise (50+ hours\/month):<\/strong> Self-hosting is mandatory. The cost savings are massive, and the performance gains directly impact developer happiness and time-to-market.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Managing the underlying OS for your CI\/CD pipeline gives you control, but it also adds a layer of responsibility. You become responsible for patching the OS and monitoring disk space. If you want the raw power of a dedicated runner without worrying about hardware failures or network uptime, ENGINYRING <a href=\"https:\/\/www.enginyring.com\/en\/virtual-servers\">Virtual Servers<\/a> provide the robust, NVMe-backed foundation your pipelines need. We handle the infrastructure availability so you can focus on shipping code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ready to turbocharge your builds? Deploy a VPS today, run the script, and watch those green checkmarks appear faster than ever before.<\/p>\n\n ","protected":false},"excerpt":{"rendered":"<p>If you are a developer or a team lead managing a growing codebase, you have likely hit &#8220;The Wall.&#8221; It usually arrives in the third week of the month as a polite but alarming email from GitHub: &#8220;You have used 80% of your included Actions minutes.&#8221; A few days later, your pipelines stop, or your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2149,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[13119,13122,13106,13113,13126,13111,13127,13114,13120,13103,13105,13125,6004,13100,13112,13128,13121,13108,13097,13123,13117,13102,13118,13129,13116,13115,13104,13107,13098,13124,13109,13101,13110,13130,13099],"class_list":["post-2148","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-automated-testing-infrastructure","tag-build-server-best-practices","tag-ci-cd-infrastructure","tag-ci-cd-pipeline-optimization","tag-continuous-integration-server","tag-debian-github-runner","tag-dedicated-build-runner","tag-developer-tools-cost","tag-devops-automation-tools","tag-devops-cost-optimization","tag-docker-layer-caching","tag-docker-prune-automation","tag-enginyring-vps","tag-faster-ci-builds","tag-github-actions-docker-caching","tag-github-actions-enterprise","tag-github-actions-overage-charges","tag-github-actions-pricing-2026","tag-github-actions-self-hosted-runner","tag-github-runner-service-installation","tag-gitlab-ci-alternative","tag-install-github-runner-linux","tag-jenkins-alternative","tag-linux-swap-for-compilation","tag-linux-vps-hosting","tag-nvme-vps-for-build-servers","tag-persistent-build-cache","tag-private-repository-security","tag-reduce-github-actions-cost","tag-secure-ci-cd-pipeline","tag-self-hosted-runner-tutorial","tag-systemd-github-runner","tag-ubuntu-github-runner","tag-unlimited-build-minutes","tag-vps-for-ci-cd"],"_links":{"self":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2148"}],"version-history":[{"count":1,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2148\/revisions"}],"predecessor-version":[{"id":2150,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2148\/revisions\/2150"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/2149"}],"wp:attachment":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}