# Install self hosted runner

1. Select Repo and go to Settings:&#x20;

![](https://3885248957-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoE4wMO1dMVDOGDjh0En7%2Fuploads%2FpEvRybHbZd2ddoyaSIbe%2F06482c597ba8ec8a1c0f6c85020526e5.png?alt=media\&token=55c15240-b9dc-4c73-97b7-e85a886c5f5e)

2\. Go to Actions --> Runners --> New self-hoster runner:&#x20;

![](https://3885248957-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoE4wMO1dMVDOGDjh0En7%2Fuploads%2FTWEyX40oIKSXNZ9Kyob0%2Fimage.png?alt=media\&token=e2978e2c-5662-41c4-9f99-444445bd75e3)

3\. Follow the instructions for the os in question (most likely Linux)&#x20;

![](https://3885248957-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoE4wMO1dMVDOGDjh0En7%2Fuploads%2FRBJDF55T8oL3oEVHmp59%2Fimage.png?alt=media\&token=b20701ff-e692-4e44-ae78-df240e309593)

{% hint style="info" %}
**NOTE: A self-hosted runner is automatically removed from GitHub if it has not connected to GitHub Actions for more than 30 days.**
{% endhint %}

4\. Use the following:

```yaml
# Use this YAML in your workflow file for each job
runs-on: self-hosted
```

### To run the runner you have 2 options:

1. Execute from folder `./run.sh`

* This will stop once you exit

1. Set up background service for this:

* Check available commands

```bash
user@linux-01:~/actions-runner$ sudo ./svc.sh 

Usage:
./svc.sh [install, start, stop, status, uninstall]
Commands:
   install [user]: Install runner service as Root or specified user.
   start: Manually start the runner service.
   stop: Manually stop the runner service.
   status: Display status of runner service.
   uninstall: Uninstall runner service.
```

* Install the service as root:

```bash
user@linux-01:~/actions-runner$ sudo ./svc.sh install
Creating launch runner in /etc/systemd/system/actions.runner.Atredies-sturdy-octo-fiesta.vor-01.service
Run as user: tech
Run as uid: 1000
gid: 100
Created symlink /etc/systemd/system/multi-user.target.wants/actions.runner.Atredies-sturdy-octo-fiesta.vor-01.service → /etc/systemd/system/actions.runner.Atredies-sturdy-octo-fiesta.vor-01.service.
```

* Start the service:

```bash
user@linux-01:~/actions-runner$ sudo ./svc.sh start

/etc/systemd/system/actions.runner.Atredies-sturdy-octo-fiesta.vor-01.service
● actions.runner.Atredies-sturdy-octo-fiesta.vor-01.service - GitHub Actions Runner (Atredies-sturdy-octo-fiesta.vor-01)
     Loaded: loaded (/etc/systemd/system/actions.runner.Atredies-sturdy-octo-fiesta.vor-01.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-01-30 19:22:33 EET; 12ms ago
   Main PID: 913 (runsvc.sh)
      Tasks: 3 (limit: 1133)
     Memory: 948.0K
        CPU: 4ms
     CGroup: /system.slice/actions.runner.Atredies-sturdy-octo-fiesta.vor-01.service
             ├─913 /bin/bash /home/tech/actions-runner/runsvc.sh
             └─915 ./externals/node12/bin/node ./bin/RunnerService.js

Jan 30 19:22:33 linux-01 systemd[1]: Started GitHub Actions Runner (Atredies-sturdy-octo…r-01).
Jan 30 19:22:33 linux-01 runsvc.sh[913]: .path=/usr/local/bin:/usr/bin:/bin:/usr/local/ga…games
Hint: Some lines were ellipsized, use -l to show in full.
```

* Check if service is running:

```bash
user@linux-01:~/actions-runner$ sudo ./svc.sh status

/etc/systemd/system/actions.runner.Atredies-sturdy-octo-fiesta.vor-01.service
● actions.runner.Atredies-sturdy-octo-fiesta.linux-01.service - GitHub Actions Runner (Atredies-sturdy-octo-fiesta.vor-01)
     Loaded: loaded (/etc/systemd/system/actions.runner.Atredies-sturdy-octo-fiesta.vor-01.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-01-30 19:22:33 EET; 4s ago
   Main PID: 913 (runsvc.sh)
      Tasks: 21 (limit: 1133)
     Memory: 36.4M
        CPU: 790ms
     CGroup: /system.slice/actions.runner.Atredies-sturdy-octo-fiesta.vor-01.service
             ├─913 /bin/bash /home/tech/actions-runner/runsvc.sh
             ├─915 ./externals/node12/bin/node ./bin/RunnerService.js
             └─924 /home/tech/actions-runner/bin/Runner.Listener run --startuptype service

Jan 30 19:22:33 linux-01 systemd[1]: Started GitHub Actions Runner (Atredies-sturdy-octo…r-01).
Jan 30 19:22:33 linux-01 runsvc.sh[913]: .path=/usr/local/bin:/usr/bin:/bin:/usr/local/ga…games
Jan 30 19:22:33 linux-01 runsvc.sh[915]: Starting Runner listener with startup type: service
Jan 30 19:22:33 linux-01 runsvc.sh[915]: Started listener process, pid: 924
Jan 30 19:22:33 linux-01 runsvc.sh[915]: Started running service
Jan 30 19:22:34 linux-01 runsvc.sh[915]: √ Connected to GitHub
Jan 30 19:22:35 linux-01 runsvc.sh[915]: Current runner version: '2.286.1'
Jan 30 19:22:35 linux-01 runsvc.sh[915]: 2022-01-30 17:22:35Z: Listening for Jobs
Hint: Some lines were ellipsized, use -l to show in full.
```

1. Check if runner is active:

* Reload the Settings tab
* Go to Actions
* Go to Runners
* New runner should be there:&#x20;

### Resources:

* [Self Hosted Runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.arkannis.net/devops/github-actions/install-self-hosted-runner.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
