๐ Configuring GitHub Actions Runner: Simple Guide
Letโs set up a GitHub Actions runner on Alpine Linux! ๐ป This tutorial shows you how to create your own automation worker that runs tasks for your GitHub projects. Itโs like having a helpful robot that does repetitive work for you! ๐
๐ค What is a GitHub Actions Runner?
A GitHub Actions runner is like a dedicated worker for your code projects! ๐ค It automatically runs tests, builds applications, and deploys software whenever you make changes to your GitHub repository.
A GitHub Actions runner is like:
- ๐ญ A factory worker who builds products automatically
- ๐ A washing machine that runs cleaning cycles
- ๐ An assistant who follows your instruction list perfectly
๐ฏ What You Need
Before we start, you need:
- โ Alpine Linux system running
- โ GitHub account with repository access
- โ Root access to your system
- โ Internet connection for downloading runner software
๐ Step 1: Prepare System
Installing Required Dependencies
Letโs start by installing everything needed for the GitHub runner. Itโs easy! ๐
What weโre doing: Installing tools and dependencies required by GitHub Actions runner.
# Update package index
apk update
# Install required packages
apk add curl bash git tar gzip
# Install Docker for containerized actions
apk add docker docker-compose
# Install Node.js for JavaScript actions
apk add nodejs npm
# Start Docker service
rc-service docker start
rc-update add docker default
# Create user for running actions
adduser -D -s /bin/bash github-runner
What this does: ๐ Your system now has all tools needed to run GitHub Actions.
Example output:
โ
Dependencies installed successfully
โ
Docker service started
โ
GitHub runner user created
What this means: Your system is ready for GitHub Actions! โ
๐ก Important Tips
Tip: Always use a dedicated user for security! ๐ก
Warning: Keep your runner token secret and secure! โ ๏ธ
๐ ๏ธ Step 2: Download and Configure Runner
Getting the GitHub Actions Runner
Now letโs download and set up the GitHub Actions runner software! ๐ฆ
What weโre doing: Downloading the runner and configuring it for your GitHub repository.
# Switch to github-runner user
su - github-runner
# Create directory for runner
mkdir -p /home/github-runner/actions-runner
cd /home/github-runner/actions-runner
# Download latest runner (check GitHub for current version)
curl -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
# Verify download (optional)
echo "29fc8cf2dab4c195bb147384e7e2c94cfd4d4022c793b346a6175435265e8153 actions-runner-linux-x64-2.311.0.tar.gz" | sha256sum -c
# Extract runner files
tar xzf ./actions-runner-linux-x64-2.311.0.tar.gz
Code explanation:
curl -L
: Downloads the runner package from GitHubtar xzf
: Extracts the compressed runner filessha256sum -c
: Verifies file integrity for security/home/github-runner/actions-runner
: Runner installation directory
Expected Output:
โ
Runner downloaded successfully
โ
File integrity verified
โ
Runner files extracted
What this means: Great job! Runner software is ready for configuration! ๐
๐ฎ Letโs Try It!
Time for hands-on practice! This is the fun part! ๐ฏ
What weโre doing: Configuring the runner to connect to your GitHub repository.
# Configure the runner (you'll need a token from GitHub)
# Go to your repo โ Settings โ Actions โ Runners โ New self-hosted runner
# Run configuration script
./config.sh --url https://github.com/YOUR-USERNAME/YOUR-REPO --token YOUR-TOKEN
# When prompted, provide:
# - Runner name: alpine-runner-01
# - Runner group: Default
# - Labels: alpine,linux,self-hosted
# - Work folder: _work
# Test runner configuration
./run.sh --once
Configuration example:
Enter the name of the runner group: [press Enter for default]
Enter the name of runner: alpine-runner-01
Enter any additional labels: alpine,linux,docker
Enter name of work folder: _work
You should see:
โ
Runner successfully configured
โ
Connected to GitHub repository
โ
Ready to process jobs
Awesome work! ๐
๐ Quick Summary Table
What to Do | Command | Result |
---|---|---|
๐ง Install deps | apk add curl bash git | โ System prepared |
๐ ๏ธ Download runner | curl -o actions-runner... | โ Runner software ready |
๐ฏ Configure | ./config.sh --url ... | โ Connected to GitHub |
๐ฎ Practice Time!
Letโs practice what you learned! Try these simple examples:
Example 1: Create Runner Service ๐ข
What weโre doing: Setting up the runner to start automatically as a system service.
# Exit from github-runner user
exit
# Create systemd service file
cat > /etc/systemd/system/github-actions-runner.service << 'EOF'
[Unit]
Description=GitHub Actions Runner
After=network.target
[Service]
Type=simple
User=github-runner
WorkingDirectory=/home/github-runner/actions-runner
ExecStart=/home/github-runner/actions-runner/run.sh
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
# Install OpenRC service instead (Alpine uses OpenRC)
cat > /etc/init.d/github-actions-runner << 'EOF'
#!/sbin/openrc-run
name="GitHub Actions Runner"
description="GitHub Actions self-hosted runner"
user="github-runner"
directory="/home/github-runner/actions-runner"
command="${directory}/run.sh"
pidfile="/var/run/${RC_SVCNAME}.pid"
depend() {
need net
after docker
}
start_pre() {
checkpath --directory --owner ${user}:${user} --mode 0755 \
/var/run/${RC_SVCNAME} /var/log/${RC_SVCNAME}
}
EOF
chmod +x /etc/init.d/github-actions-runner
# Start and enable service
rc-service github-actions-runner start
rc-update add github-actions-runner default
What this does: Makes the runner start automatically when system boots! ๐
Example 2: Create Test Workflow ๐ก
What weโre doing: Creating a simple workflow to test your new runner.
# Create example workflow file (do this in your GitHub repo)
mkdir -p .github/workflows
cat > .github/workflows/test-alpine-runner.yml << 'EOF'
name: Test Alpine Runner
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test-on-alpine:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Show system info
run: |
echo "๐๏ธ Running on Alpine Linux!"
uname -a
cat /etc/alpine-release
whoami
pwd
- name: Test Docker
run: |
docker --version
docker run --rm hello-world
- name: Test Node.js
run: |
node --version
npm --version
echo "console.log('Hello from Alpine runner!');" | node
- name: Success message
run: |
echo "โ
Alpine Linux runner working perfectly!"
echo "๐ Your CI/CD pipeline is ready!"
EOF
echo "๐ Upload this workflow to your GitHub repository!"
echo "๐ Location: .github/workflows/test-alpine-runner.yml"
What this does: Tests all runner capabilities with a real workflow! ๐
๐จ Fix Common Problems
Problem 1: Runner fails to start โ
What happened: The runner service wonโt start properly. How to fix it: Check logs and permissions!
# Check runner status
rc-service github-actions-runner status
# View runner logs
tail -f /var/log/github-actions-runner/current
# Check file permissions
ls -la /home/github-runner/actions-runner/
# Fix permissions if needed
chown -R github-runner:github-runner /home/github-runner/
Problem 2: Actions fail with permission errors โ
What happened: GitHub Actions canโt access Docker or other services. How to fix it: Add user to necessary groups!
# Add github-runner to docker group
adduser github-runner docker
# Add to other necessary groups
adduser github-runner wheel
# Restart runner service
rc-service github-actions-runner restart
# Test Docker access
su - github-runner -c "docker ps"
Donโt worry! These problems happen to everyone. Youโre doing great! ๐ช
๐ก Simple Tips
- Monitor regularly ๐ - Check runner status and logs
- Keep updated ๐ฑ - Update runner software regularly
- Secure tokens ๐ค - Rotate runner tokens periodically
- Scale wisely ๐ช - Add more runners when needed
โ Check Everything Works
Letโs make sure everything is working:
# Check runner service status
rc-service github-actions-runner status
# Verify runner is connected to GitHub
su - github-runner -c "cd actions-runner && ./run.sh --once"
# Test Docker functionality
docker run --rm hello-world
# Check available disk space for builds
df -h /home/github-runner/
Good output:
โ
Runner service is running
โ
Connected to GitHub successfully
โ
Docker working properly
โ
Sufficient disk space available
๐ What You Learned
Great job! Now you can:
- โ Install and configure GitHub Actions runner
- โ Set up automatic service startup
- โ Create and test CI/CD workflows
- โ Troubleshoot common runner issues
๐ฏ Whatโs Next?
Now you can try:
- ๐ Learning about advanced workflow strategies
- ๐ ๏ธ Setting up multiple runners for parallel jobs
- ๐ค Helping others automate their development processes
- ๐ Building complex CI/CD pipelines with testing and deployment!
Remember: Every expert was once a beginner. Youโre doing amazing! ๐
Keep automating and youโll save tons of time on repetitive tasks! ๐ซ