Merge pull request 'use the runner binary instead of building from source' (#8) from earl-warren/setup-forgejo:wip-use-binary into main

Reviewed-on: https://code.forgejo.org/actions/setup-forgejo/pulls/8
This commit is contained in:
earl-warren 2023-04-04 13:06:42 +00:00
commit f66ab11375
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 |
| password | Administrator password | `false` | admin1234 |
| 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 |
| lxc-ip-prefix | Class C IP prefix used by LXC | `false` | 10.0.23 |
<!-- action-docs-inputs -->

View file

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

View file

@ -4,55 +4,38 @@
set -ex
function dependencies() {
if ! which go > /dev/null ; then
apt-get update
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
if ! which curl daemon > /dev/null ; then
apt-get install -y -qq curl daemon
fi
}
function checkout() {
local git="$1"
if ! test -d forgejo-runner ; then
git clone $git forgejo-runner
fi
}
function download() {
local runner_repository="$1"
local version="$2"
function build() {
local version="$1"
(
cd forgejo-runner
git checkout $version
make build
)
curl -L --fail -sS $runner_repository/releases/download/$version/forgejo-runner-amd64 > /bin/forgejo-runner
chmod 755 /bin/forgejo-runner
}
function register() {
local forgejo="$1"
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() {
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
cat forgejo-runner.log
}
function setup() {
local git="${1:-https://codeberg.org/forgejo/runner}"
local version="${2:-v1.4.1}"
local runner_repository="${1:-https://code.forgejo.org/forgejo/runner}"
local version="${2:-v1.5.0}"
local forgejo="${3:-http://$(cat forgejo-ip):3000/}"
dependencies
checkout $git
build $version
download $runner_repository $version
register $forgejo
run
}