From ae0922ec648f84a55a98473f91e435c208def3a2 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 4 Apr 2023 12:51:16 +0200 Subject: [PATCH] use the runner binary instead of building from source --- README.md | 2 +- action.yml | 2 +- forgejo-runner.sh | 41 ++++++++++++----------------------------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 55a87cb..03da88c 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/action.yml b/action.yml index f2523ae..e765be3 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/forgejo-runner.sh b/forgejo-runner.sh index 0862e8c..16b8236 100755 --- a/forgejo-runner.sh +++ b/forgejo-runner.sh @@ -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 }