mirror of
https://code.forgejo.org/actions/setup-forgejo.git
synced 2024-11-24 03:01:04 -05:00
Merge pull request 'do not try to install the runner if it already available' (#9) from earl-warren/setup-forgejo:wip-use-binary into main
Reviewed-on: https://code.forgejo.org/actions/setup-forgejo/pulls/9 Reviewed-by: dachary <dachary@noreply.code.forgejo.org>
This commit is contained in:
commit
8c854211ba
4 changed files with 51 additions and 4 deletions
|
@ -8,6 +8,14 @@ jobs:
|
||||||
set -x
|
set -x
|
||||||
LXC_IP_PREFIX=10.0.9 ./forgejo-dependencies.sh
|
LXC_IP_PREFIX=10.0.9 ./forgejo-dependencies.sh
|
||||||
./forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo:1.19
|
./forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo:1.19
|
||||||
|
#
|
||||||
|
# Uncomment the following for a shortcut to debugging the Forgejo runner.
|
||||||
|
# It will build the runner from a designated repository and branch instead of
|
||||||
|
# downloading it from a canonical release.
|
||||||
|
#
|
||||||
|
# ./forgejo-test-helper.sh build_runner http://code.forgejo.org/forgejo/runner branch-under-debug
|
||||||
|
# export PATH=$(pwd)/forgejo-runner:$PATH
|
||||||
|
#
|
||||||
./forgejo-runner.sh setup
|
./forgejo-runner.sh setup
|
||||||
export FORGEJO_RUNNER_LOGS=forgejo-runner.log
|
export FORGEJO_RUNNER_LOGS=forgejo-runner.log
|
||||||
./forgejo-test-helper.sh run_workflow testdata/demo http://root:admin1234@$(cat forgejo-ip):3000 root demo setup-forgejo $(cat forgejo-token) > /tmp/output
|
./forgejo-test-helper.sh run_workflow testdata/demo http://root:admin1234@$(cat forgejo-ip):3000 root demo setup-forgejo $(cat forgejo-token) > /tmp/output
|
||||||
|
|
|
@ -21,6 +21,11 @@ description: |
|
||||||
Create the repository `$forgejo/root/testrepo` and populate it with the
|
Create the repository `$forgejo/root/testrepo` and populate it with the
|
||||||
content of the `testrepo` directory. The SHA of the tip of the repository
|
content of the `testrepo` directory. The SHA of the tip of the repository
|
||||||
is in the output, starting with `sha=`.
|
is in the output, starting with `sha=`.
|
||||||
|
* `forgejo-test-helper.sh build_runner $forgejo/forgejo/runner v1.4.1`
|
||||||
|
Builds the forgejo runner from source in `./forgejo-runner/forgejo-runner`.
|
||||||
|
`export PATH=$(pwd)/forgejo-runner:$PATH` will ensure that calling `forgejo-runner.sh`
|
||||||
|
will use this binary instead of downloading a released version of the runner.
|
||||||
|
If the version is not specified, build from the main branch.
|
||||||
|
|
||||||
The combination of `push_self_action` and `run_workflow` allows to
|
The combination of `push_self_action` and `run_workflow` allows to
|
||||||
run Forgejo Actions workflows from `testrepo` that use the action
|
run Forgejo Actions workflows from `testrepo` that use the action
|
||||||
|
|
|
@ -13,8 +13,10 @@ function download() {
|
||||||
local runner_repository="$1"
|
local runner_repository="$1"
|
||||||
local version="$2"
|
local version="$2"
|
||||||
|
|
||||||
curl -L --fail -sS $runner_repository/releases/download/$version/forgejo-runner-amd64 > /bin/forgejo-runner
|
if ! which forgejo-runner > /dev/null; then
|
||||||
chmod 755 /bin/forgejo-runner
|
curl -L --fail -sS $runner_repository/releases/download/$version/forgejo-runner-amd64 > /bin/forgejo-runner
|
||||||
|
chmod 755 /bin/forgejo-runner
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function register() {
|
function register() {
|
||||||
|
@ -24,7 +26,8 @@ function register() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
daemon --chdir=$(pwd) --unsafe --pidfile=$(pwd)/forgejo-runner-pid --errlog=$(pwd)/forgejo-runner.log --output=$(pwd)/forgejo-runner.log /bin/forgejo-runner daemon
|
rm -f forgejo-runner.log
|
||||||
|
daemon --chdir=$(pwd) --unsafe --pidfile=$(pwd)/forgejo-runner-pid --errlog=$(pwd)/forgejo-runner.log --output=$(pwd)/forgejo-runner.log forgejo-runner daemon
|
||||||
sleep 1
|
sleep 1
|
||||||
cat forgejo-runner.log
|
cat forgejo-runner.log
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,37 @@ DIR=$(mktemp -d)
|
||||||
|
|
||||||
trap "rm -fr $DIR" EXIT
|
trap "rm -fr $DIR" EXIT
|
||||||
|
|
||||||
|
function dependency_go() {
|
||||||
|
if ! which go > /dev/null ; then
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y -qq wget tar
|
||||||
|
wget https://go.dev/dl/go1.20.3.linux-amd64.tar.gz
|
||||||
|
tar zxf go1.20.3.linux-amd64.tar.gz
|
||||||
|
export PATH=$PATH:$(pwd)/go/bin
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkout() {
|
||||||
|
local git="$1"
|
||||||
|
rm -fr forgejo-runner
|
||||||
|
git clone $git forgejo-runner
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_runner() {
|
||||||
|
local git="$1"
|
||||||
|
local version="${2:-main}"
|
||||||
|
|
||||||
|
(
|
||||||
|
checkout "$git"
|
||||||
|
dependency_go
|
||||||
|
cd forgejo-runner
|
||||||
|
git checkout "$version"
|
||||||
|
make build
|
||||||
|
)
|
||||||
|
export PATH=$PATH:$(pwd)/forgejo-runner
|
||||||
|
forgejo-runner --version
|
||||||
|
}
|
||||||
|
|
||||||
function api() {
|
function api() {
|
||||||
method=$1
|
method=$1
|
||||||
shift
|
shift
|
||||||
|
|
Loading…
Reference in a new issue