Wiki do Tiozão do Linux

Runners GitHub Auto Hospedados

Você pode hospedar seus próprios runners e personalizar o ambiente usado para executar jobs em seus workflows do GitHub Actions

Github Self Host Runners

A documentação oficial está disponível em
https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners

Objetivo

Instanciar um runner usado com GitHub Actions workflows.

Requisitos

Utilizarei um Linux na OCI com arquitetura ARM64, que já tenho e com o docker instalado.

Nível dos Runners

Instalação

Acesse o servidor como um usuário não root, pois o runner irá rodar sem previlégios de root.

Para o Ubuntu Linux, o usuário padrão é ubuntu.

No meu caso o usuário opc é o usuário padrão do meu AlmaLinux.

┌─[root@oracle-04]─[~]─[Sat Jun 14 19:20:01]
└──╼ # su - opc
[opc@oracle-04 ~]$

Acesse a URL da sua Organização ou Repositório no GitHub

Utilizarei a minha Organização https://github.com/Tiozao-do-Linux

Crie um novo runner:Settings -> Actions -> Runners -> New runner ->
New Self-hosted Runner

Siga as orientações da página:

# Create a folder
$ mkdir actions-runner && cd actions-runner# Download the latest runner package
$ curl -o actions-runner-linux-arm64-2.325.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.325.0/actions-runner-linux-arm64-2.325.0.tar.gz# Optional: Validate the hash
$ echo "0e916ad0d354089d320011c132d46bdbe3353c8b925a2e1056c7c8e85d2f2490  actions-runner-linux-arm64-2.325.0.tar.gz" | shasum -a 256 -c# Extract the installer
$ tar xzf ./actions-runner-linux-arm64-2.325.0.tar.gz

No final dessa etapa você terá:

[opc@oracle-04 actions-runner]$ pwd
/home/opc/actions-runner
[opc@oracle-04 actions-runner]$ ls -la
total 88
drwxr-xr-x. 5 opc opc  4096 Jun 14 10:39 .
drwx------. 5 opc opc   131 Jun 14 10:31 ..
-rw-r--r--. 1 opc opc 80588548 Jun 14 19:38 actions-runner-linux-arm64-2.325.0.tar.gz
drwxr-xr-x. 4 opc opc 12288 Jun 14 10:39 bin
-rwxr-xr-x. 1 opc opc  2458 Jun  2 14:42 config.sh
-rw-r--r--. 1 opc opc   268 Jun 14 10:32 .credentials
-rw-------. 1 opc opc  1667 Jun 14 10:31 .credentials_rsaparams
drwxr-xr-x. 2 opc opc  4096 Jun 14 10:39 _diag
-rw-r--r--. 1 opc opc    17 Jun 14 10:31 .env
-rwxr-xr-x. 1 opc opc   646 Jun  2 14:42 env.sh
drwxr-xr-x. 3 opc opc    20 Jun  2 14:43 externals
-rw-r--r--. 1 opc opc   109 Jun 14 10:31 .path
-rw-r--r--. 1 opc opc  1619 Jun  2 14:42 run-helper.cmd.template
-rwxr-xr-x. 1 opc opc  2663 Jun 14 10:36 run-helper.sh
-rwxr-xr-x. 1 opc opc  2663 Jun  2 14:42 run-helper.sh.template
-rw-r--r--. 1 opc opc   380 Jun 14 10:32 .runner
-rwxr-xr-x. 1 opc opc  2535 Jun  2 14:42 run.sh
-rwxr-xr-x. 1 opc opc   532 Jun 14 10:39 runsvc.sh
-rwxr-xr-x. 1 opc opc    65 Jun  2 14:42 safe_sleep.sh
-rw-r--r--. 1 opc opc    49 Jun 14 10:39 .service
-rwxr-xr-x. 1 opc opc  5216 Jun 14 10:32 svc.sh
[opc@oracle-04 actions-runner]$

Na seção configure:

Note que a URL (https://github.com/Tiozao-do-Linux) deve ser a URL do seu repositório ou da sua organização.

# Create the runner and start the configuration experience
$ ./config.sh --url https://github.com/Tiozao-do-Linux --token XXXXXXXXXXXXXXXXX
--------------------------------------------------------------------------------
|        ____ _ _   _   _       _          _        _   _                      |
|       / ___(_) |_| | | |_   _| |__      / \   ___| |_(_) ___  _ __  ___      |
|      | |  _| | __| |_| | | | | '_ \    / _ \ / __| __| |/ _ \| '_ \/ __|     |
|      | |_| | | |_|  _  | |_| | |_) |  / ___ \ (__| |_| | (_) | | | \__ \     |
|       \____|_|\__|_| |_|\__,_|_.__/  /_/   \_\___|\__|_|\___/|_| |_|___/     |
|                                                                              |
|                       Self-hosted runner registration                        |
|                                                                              |
--------------------------------------------------------------------------------

# Authentication

√ Connected to GitHub

# Runner Registration

Enter the name of the runner group to add this runner to: [press Enter for Default]

Enter the name of runner: [press Enter for oracle-04]

This runner will have the following labels: 'self-hosted', 'Linux', 'ARM64'
Enter any additional labels (ex. label-1,label-2): [press Enter to skip] oracle-04

√ Runner successfully added
√ Runner connection is good

# Runner settings

Enter name of work folder: [press Enter for _work]

√ Settings Saved.

Perceba que um label oracle-04 foi adicionado para diferenciar este runner de possíveis outros runners.

Executar o Runnner

Essa etapa de executar seu runner pode ser suprimida, pois utilizaremos um serviço correspondente à esse runner.

Se você rodar, seu terminal ficará preso e só será liberado com CTRL+C, interrompendo o runner.

# Last step, run it!
$ ./run.sh

√ Connected to GitHub

Current runner version: '2.325.0'
2025-06-14 14:33:04Z: Listening for Jobs

^C
Exiting...

Vamos criar um serviço desse runner

sudo ./svc.sh install

Creating launch runner in /etc/systemd/system/actions.runner.Tiozao-do-Linux.oracle-04.service
Run as user: opc
Run as uid: 1000
gid: 1000
Created symlink /etc/systemd/system/multi-user.target.wants/actions.runner.Tiozao-do-Linux.oracle-04.service → /etc/systemd/system/actions.runner.Tiozao-do-Linux.oracle-04.service.

Inicializar o serviço para que inicie junto com o start do servidor:

sudo systemctl enable --now actions.runner.Tiozao-do-Linux.oracle-04.service

Created symlink /etc/systemd/system/multi-user.target.wants/actions.runner.Tiozao-do-Linux.oracle-04.service → /etc/systemd/system/actions.runner.Tiozao-do-Linux.oracle-04.service.

Conferindo seu runner no GitHub

Acesse a URL da sua organização ou do seu repositório e veja se seu Runner Self-Hosted está ativo e com os labels informados.

Executando o runner através de um workflow

Cada job do seu workflow poderá ser executado com esse runner utilizando algum dos labels definidos.
runs-on: self-hosted ou Linux ou ARM64 ou oracle-04

Se houver mais de um runner com o label self-hosted ou Linux ou ARM64, o job poderá ser executado aleatoriamente em qualquer runner.

Se desejar que seja executado APENAS neste runner, tenha certeza que no arquivo YML do workflow tenha:

runs-on: oracle-04

Runners Self-hosts em seus repositórios públicos

Por default um runner vem associado a um grupo Default e sua organização não habilita os repositórios de a utilzarem esse runner.

Vamos permitir que qualquer repositório de sua organização possa utilizar tal runner.

Na URL de sua organização faça:
Settings -> Actions -> Runner groups -> Allow public repositories

Agora na URL de seu repositório será visível o runner oracle-04 com seus labels.

Referências