Home Self-Hosting Gitea with act_runner
Post
Cancel

Self-Hosting Gitea with act_runner

Today I will be writing about working with Gitea and the act_runner program to self-host a code repository. This is part of a multi-part series walkthrough for running Gitea and act_runner on a virtual machine or Orange Pi, a Raspberry Pi alternative.

Depending on your environment and architecture, the exact steps may vary. First step is to get Gitea installed. Their documentation is through and easy to follow. I will be installing Gitea directly on the underlying operating system for the purpose of this guide. It should be noted that a text editor like vim or nano is needed as well as curl or wget for these steps.

Once the Gitea setup is complete, the next step is to install Docker Engine to support the act_runner daemon. Platform-specific steps for installing Docker Engine can be found here.

At this point, running sudo docker run hello-world should be successful.

Next up, install the go toolchain. Again, this is architecture-specific. This is to support the act_runner binary. Download the act_runner binary that matches your architecture from here. Extract it if necessary and move it to /usr/local/bin/act_runner and add the execute bit.

1
2
# mv act_runner-0.2.6-linux-amd64 /usr/local/bin/act_runner
# chmod +x /usr/local/bin/act_runner

Make a directory in /etc/ to store the act_runner configuration file and generate the base configuration file for act_runner to use.

1
2
3
# mkdir /etc/act_runner
# cd /etc/act_runner
# act_runner generate-config > /etc/act_runner/config.yaml

Gitea does not have actions enabled by default as of this post. Edit the app.ini for Gitea to add the following block:

1
2
[actions]
ENABLED=true

Reload Gitea for these changes to take effect. Log back in, select “Profile and Settings” in the top right and click Actions –> Runners on the left panel. Click the drop down “Create new Runner” and copy the registration token.

Back over to the shell, start up act_runner to register in the foreground by executing:

1
2
# cd /etc/act_runner
# act_runner register

This will prompt for information pertaining to the install. Name and labels can be left at the default. Once registered, act_runner can now be run in the background as a systemd service. My service file looks like the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# systemctl cat act_runner
# /etc/systemd/system/act_runner.service
[Unit]
Description=Gitea Actions runner
Documentation=https://gitea.com/gitea/act_runner
After=gitea.service
After=network.target
After=docker.service

[Service]
ExecStart=/usr/local/bin/act_runner daemon -c /etc/act_runner/config
ExecReload=/bin/kill -s HUP $MAINPID
WorkingDirectory=/etc/act_runner
Restart=always
KillMode=mixed

[Install]
WantedBy=default.target

Once the service file is created, issue systemctl daemon-reload to make the service available and systemctl enable act_runner.service --now to enable the service at boot and start the service immediately. The runner should now show up under the “Runners” page in Gitea Administration.

To use the runner in a repository, there is a checkbox under the repository settings that needs to be ticked.

That wraps up the introduction and initial configuration of Gitea and the act_runner daemon/service.

This post is licensed under CC BY 4.0 by the author.