Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zhanglianxin/3afa003d440f46e00dc51b930e57d0c1 to your computer and use it in GitHub Desktop.
Save zhanglianxin/3afa003d440f46e00dc51b930e57d0c1 to your computer and use it in GitHub Desktop.

Gitea Act Runner

Requirements

Docker engine: https://docs.docker.com/engine/install/

Unprivileged user:

# the username corresponds to the User command in service configuration file
sudo useradd -r -s /usr/sbin/nologin -m -c "Gitea Actions Runner" act_runner

Add act_runner to docker group:

sudo usermod -aG docker act_runner

Installation with binary

Preview/Prepare the/your Systemd service configuration file

ref: Start the runner with Systemd

Download the binary

VERSION=0.2.11

# the path corresponds to the ExecStart command
sudo curl -sSLo /usr/local/bin/act_runner \
    https://dl.gitea.com/act_runner/${VERSION}/act_runner-${VERSION}-linux-amd64

sudo chmod +x /usr/local/bin/act_runner

Configuration

  1. Obtain a registration token:

    token level:

    • Instance level: for global
    • Organization level: for single user/org, or individual
    • Repository level: for single repo
  2. Generate config:

    sudo mkdir -p /etc/act_runner/
    
    # the path corresponds to the --config flag in the ExecStart command
    act_runner generate-config | sudo tee /etc/act_runner/config.yaml
    
    sudo chown -R act_runner:act_runner /etc/act_runner/
  3. Register runner:

    # the path corresponds to the WorkingDirectory command
    sudo mkdir -p /var/lib/act_runner
    
    cd /var/lib/act_runner
    
    act_runner --config /etc/act_runner/config.yaml register
    
    sudo chown -R act_runner:act_runner /var/lib/act_runner
  4. Start the runner with Systemd

    cat << 'EOF' | sudo tee /etc/systemd/system/act_runner.service
    [Unit]
    Description=Gitea Actions runner
    Documentation=https://gitea.com/gitea/act_runner
    After=docker.service
    
    [Service]
    ExecStart=/usr/local/bin/act_runner daemon --config /etc/act_runner/config.yaml
    ExecReload=/bin/kill -s HUP $MAINPID
    WorkingDirectory=/var/lib/act_runner
    TimeoutSec=0
    RestartSec=10
    Restart=always
    User=act_runner
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
    sudo systemctl start act_runner
    # After confirming that it works properly
    sudo systemctl enable --now act_runner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment