use the runner binary instead of building from source

This commit is contained in:
Earl Warren 2023-04-04 12:51:16 +02:00
parent 9b17c14d9d
commit ae0922ec64
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 14 additions and 31 deletions

View file

@ -40,7 +40,7 @@ It can only be run on the `self-hosted` platform, running on a host with LXC ins
| user | Administrator user name | `false` | root | | user | Administrator user name | `false` | root |
| password | Administrator password | `false` | admin1234 | | password | Administrator password | `false` | admin1234 |
| runner | Runner git repository | `false` | https://code.forgejo.org/forgejo/runner | | runner | Runner git repository | `false` | https://code.forgejo.org/forgejo/runner |
| runner-version | Runner version | `false` | v1.4.1 | | runner-version | Runner version | `false` | v1.5.0 |
| container | Name of the container running the Forgejo instance | `false` | forgejo | | container | Name of the container running the Forgejo instance | `false` | forgejo |
| lxc-ip-prefix | Class C IP prefix used by LXC | `false` | 10.0.23 | | lxc-ip-prefix | Class C IP prefix used by LXC | `false` | 10.0.23 |
<!-- action-docs-inputs --> <!-- action-docs-inputs -->

View file

@ -44,7 +44,7 @@ inputs:
default: 'https://code.forgejo.org/forgejo/runner' default: 'https://code.forgejo.org/forgejo/runner'
runner-version: runner-version:
description: 'Runner version' description: 'Runner version'
default: 'v1.4.1' default: 'v1.5.0'
container: container:
description: 'Name of the container running the Forgejo instance' description: 'Name of the container running the Forgejo instance'
default: 'forgejo' default: 'forgejo'

View file

@ -4,55 +4,38 @@
set -ex set -ex
function dependencies() { function dependencies() {
if ! which go > /dev/null ; then if ! which curl daemon > /dev/null ; then
apt-get update apt-get install -y -qq curl daemon
apt-get install -y -qq wget tar
wget https://go.dev/dl/go1.20.2.linux-amd64.tar.gz
tar zxf go1.20.2.linux-amd64.tar.gz
export PATH=$PATH:$(pwd)/go/bin
fi
if ! which make daemon > /dev/null ; then
apt-get install -y -qq make daemon
fi fi
} }
function checkout() { function download() {
local git="$1" local runner_repository="$1"
if ! test -d forgejo-runner ; then local version="$2"
git clone $git forgejo-runner
fi
}
function build() { curl -L --fail -sS $runner_repository/releases/download/$version/forgejo-runner-amd64 > /bin/forgejo-runner
local version="$1" chmod 755 /bin/forgejo-runner
(
cd forgejo-runner
git checkout $version
make build
)
} }
function register() { function register() {
local forgejo="$1" local forgejo="$1"
docker exec --user 1000 forgejo forgejo actions --registration-token-admin > forgejo-runner-token docker exec --user 1000 forgejo forgejo actions --registration-token-admin > forgejo-runner-token
timeout --signal=KILL 30 ./forgejo-runner/forgejo-runner register --no-interactive --instance "$forgejo" --name runner --token $(cat forgejo-runner-token) --labels ubuntu-latest:docker://node:16-buster,self-hosted timeout --signal=KILL 30 forgejo-runner register --no-interactive --instance "$forgejo" --name runner --token $(cat forgejo-runner-token) --labels ubuntu-latest:docker://node:16-buster,self-hosted
} }
function run() { function run() {
daemon --chdir=$(pwd) --unsafe --pidfile=$(pwd)/forgejo-runner-pid --errlog=$(pwd)/forgejo-runner.log --output=$(pwd)/forgejo-runner.log ./forgejo-runner/forgejo-runner daemon daemon --chdir=$(pwd) --unsafe --pidfile=$(pwd)/forgejo-runner-pid --errlog=$(pwd)/forgejo-runner.log --output=$(pwd)/forgejo-runner.log /bin/forgejo-runner daemon
sleep 1 sleep 1
cat forgejo-runner.log cat forgejo-runner.log
} }
function setup() { function setup() {
local git="${1:-https://codeberg.org/forgejo/runner}" local runner_repository="${1:-https://code.forgejo.org/forgejo/runner}"
local version="${2:-v1.4.1}" local version="${2:-v1.5.0}"
local forgejo="${3:-http://$(cat forgejo-ip):3000/}" local forgejo="${3:-http://$(cat forgejo-ip):3000/}"
dependencies dependencies
checkout $git download $runner_repository $version
build $version
register $forgejo register $forgejo
run run
} }