Introduction
To be able to use Gitea's Actions, you need to use Gitea's act runners. They are based on Gitea's fork of act.
Recommendations
Gitea's page recommend running jobs in a docker container, so you might need to install docker first, and make sure that the docker daemon is running. If you want to run the tests on Windows, macOS and FreeBSD however, you will have to run them directly on the hosts.
Special note about FreeBSD, you should be able to run them in a jail which will provide additional isolation.
Setup
This page should cover most usages.
Running on host machines
For those machines you'll want to replace the labels in the config.yaml
. Here we use latest, but it's better to specify the version to separate them, in case you have multiple versions. I would also recommend creating dedicated users with as a little rights as possible.
Windows
labels:
- "windows-latest:host"
macOS
For windows you'll want to replace the labels in the config.yaml
labels:
- "macOS-latest:host"
You can make the act_runner run as a service as well. See the example on their wiki
FreeBSD
labels:
- "FreeBSD-latest:host"
To run the service as a daemon i used the following shell file: NOTE: Killing the service doesn't work, I might have messed up a step.
#!/bin/sh
#
# PROVIDE: act_runner
# REQUIRE: NETWORK
#
# Optional flags that control the behavior of this script.
# See the startrc(8) man page for more details.
#
# NOTE: This script doesn't support restart yet.
#
# Add commands as desired; see rc.local(8) for examples.
#
# PROVIDE: act_runner
# REQUIRE: NETWORK
#
user="Gitea"
command="/usr/bin/act_runner daemon"
name="act_runner"
desc="Runs the act_runner daemon"
pidfile="/var/run/$name.pid"
start()
{
echo -n "Starting $name: "
cd "/home/$user" && daemon --user "$user" $command >> $pidfile 2>&1
echo "done"
}
stop()
{
echo -n "Stopping $name: "
kill `cat $pidfile`
rm -f $pidfile
echo "done"
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
Limitations
Runners can only be registered for one place at a time.
Currently, a runner can only listen to one source of actions (See this ticket). If you want to register it on multiple places, you need to either run multiple instances, or put it higher up in hierarchy. Currently you can do repository, project, user, and instance.
Malformed YAML files will crash the agent. You'll have to restart it manually and kill the lingering dockers.
---
name: pre-commit
on:
- push
- pull_request
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4@master
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1
Rootless dockers
I haven't managed to set it up. The image just fails.