mirror of
https://code.forgejo.org/actions/setup-forgejo.git
synced 2024-11-23 16:41:00 -05:00
Merge pull request 'forgejo-runner needs an IP, not localhost for the artifacts server' (#110) from earl-warren/setup-forgejo:wip-cleanup into main
Reviewed-on: https://code.forgejo.org/actions/setup-forgejo/pulls/110 Reviewed-by: dachary <dachary@noreply.code.forgejo.org>
This commit is contained in:
commit
0720d52456
7 changed files with 25 additions and 18 deletions
|
@ -48,7 +48,7 @@ jobs:
|
|||
LXC_IP_PREFIX=10.0.10 forgejo-dependencies.sh
|
||||
|
||||
forgejo-binary.sh ensure_user forgejo
|
||||
chown forgejo $DIR /usr/local/bin
|
||||
chown forgejo $DIR
|
||||
su -c "DIR=$DIR bash -x forgejo-binary.sh setup root admin1234 ${{ matrix.binary }}" forgejo
|
||||
|
||||
su -c "DIR=$DIR bash -x forgejo-runner.sh setup" forgejo
|
||||
|
|
|
@ -98,7 +98,7 @@ runs:
|
|||
fi
|
||||
if test "${{ inputs.binary }}"; then
|
||||
forgejo-binary.sh ensure_user forgejo
|
||||
chown forgejo $(pwd) /usr/local/bin
|
||||
chown forgejo $(pwd)
|
||||
su -c "DIR=$(pwd) forgejo-binary.sh setup ${{ inputs.user }} ${{ inputs.password }} ${{ inputs.binary }}" forgejo
|
||||
su -c "DIR=$(pwd) forgejo-runner.sh setup ${{ inputs.runner }} ${{ inputs.runner-version }} $(cat forgejo-url)" forgejo
|
||||
else
|
||||
|
|
|
@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH}
|
|||
|
||||
[server]
|
||||
APP_DATA_PATH = ${WORK_PATH}/data
|
||||
DOMAIN = ${IP}
|
||||
HTTP_PORT = 3000
|
||||
LFS_START_SERVER = true
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ function create_user() {
|
|||
|
||||
$DIR/forgejocli admin user create --admin --username "$user" --password "$password" --email "$user@example.com"
|
||||
$DIR/forgejocli admin user generate-access-token -u "$user" --raw --scopes all > $DIR/forgejo-token
|
||||
export DOT=$DIR
|
||||
local url="http://$(cat $DIR/forgejo-ip):3000"
|
||||
echo "$url" > $DIR/forgejo-url
|
||||
echo "http://${user}:${password}@$(cat $DIR/forgejo-ip):3000" > $DIR/forgejo-auth-url
|
||||
|
@ -78,6 +77,10 @@ function create_user() {
|
|||
forgejo-curl.sh api_json $url/api/forgejo/v1/version
|
||||
}
|
||||
|
||||
function myip() {
|
||||
hostname -I | cut -f1 -d' '
|
||||
}
|
||||
|
||||
function start_forgejo() {
|
||||
local work_path=$DIR/forgejo-work-path
|
||||
daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $DIR/forgejo --config $work_path/app.ini --work-path $work_path
|
||||
|
@ -88,7 +91,7 @@ function start_forgejo() {
|
|||
fi
|
||||
echo "$DIR/forgejo --config $work_path/app.ini --work-path $work_path" '"$@"' > $DIR/forgejocli
|
||||
chmod +x $DIR/forgejocli
|
||||
hostname -I | cut -f1 -d' ' > $DIR/forgejo-ip
|
||||
myip > $DIR/forgejo-ip
|
||||
}
|
||||
|
||||
function reset_forgejo() {
|
||||
|
@ -96,7 +99,7 @@ function reset_forgejo() {
|
|||
local work_path=$DIR/forgejo-work-path
|
||||
rm -fr $work_path
|
||||
mkdir -p $work_path
|
||||
WORK_PATH=$work_path envsubst < $SELF_DIR/$config-app.ini > $work_path/app.ini
|
||||
IP=$(myip) WORK_PATH=$work_path envsubst < $SELF_DIR/$config-app.ini > $work_path/app.ini
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
|
|
|
@ -66,16 +66,18 @@ function checkout() {
|
|||
function build_runner() {
|
||||
local git="$1"
|
||||
local version="${2:-main}"
|
||||
local dir=$(mktemp -d)
|
||||
local dir="$3"
|
||||
|
||||
local tmp=$(mktemp -d)
|
||||
(
|
||||
cd $dir
|
||||
cd $tmp
|
||||
checkout "$git"
|
||||
dependency_go
|
||||
cd forgejo-runner
|
||||
git checkout "$version"
|
||||
make build
|
||||
)
|
||||
mv $dir/forgejo-runner/forgejo-runner /usr/local/bin
|
||||
mv $tmp/forgejo-runner/forgejo-runner $dir
|
||||
forgejo-runner --version
|
||||
rm -fr "$dir"
|
||||
rm -fr "$tmp"
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ function download() {
|
|||
local runner_repository="$1"
|
||||
local version="$2"
|
||||
|
||||
if ! which forgejo-runner > /dev/null; then
|
||||
if ! curl -L --fail -sS $runner_repository/releases/download/$version/forgejo-runner-${version#v}-linux-amd64 > /usr/local/bin/forgejo-runner ; then
|
||||
if ! which $DIR/forgejo-runner > /dev/null; then
|
||||
if ! curl -L --fail -sS $runner_repository/releases/download/$version/forgejo-runner-${version#v}-linux-amd64 > $DIR/forgejo-runner ; then
|
||||
# backward compatibility for for the naming scheme prior to 3.0.0
|
||||
curl -L --fail -sS $runner_repository/releases/download/$version/forgejo-runner-linux-amd64 > /usr/local/bin/forgejo-runner
|
||||
curl -L --fail -sS $runner_repository/releases/download/$version/forgejo-runner-linux-amd64 > $DIR/forgejo-runner
|
||||
fi
|
||||
chmod 755 /usr/local/bin/forgejo-runner
|
||||
chmod 755 $DIR/forgejo-runner
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ function register() {
|
|||
$DIR/forgejocli actions generate-runner-token | tee $DIR/forgejo-runner-token
|
||||
(
|
||||
cd $DIR
|
||||
timeout --signal=KILL 30 forgejo-runner register --no-interactive --instance "$forgejo" --name runner --token $(cat $DIR/forgejo-runner-token) --labels docker:docker://code.forgejo.org/oci/node:20-bookworm,ubuntu-latest:docker://code.forgejo.org/oci/node:20-bookworm,self-hosted:lxc://debian:bookworm
|
||||
timeout --signal=KILL 30 $DIR/forgejo-runner register --no-interactive --instance "$forgejo" --name runner --token $(cat $DIR/forgejo-runner-token) --labels docker:docker://code.forgejo.org/oci/node:20-bookworm,ubuntu-latest:docker://code.forgejo.org/oci/node:20-bookworm,self-hosted:lxc://debian:bookworm
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ function run() {
|
|||
daemon --chdir=$DIR --unsafe \
|
||||
--env="TERM=$TERM" --env="HOME=$(cat $DIR/forgejo-runner-home)" --env="PATH=$PATH" --env="USER=$USER" --env="TERM=dumb" --env="USERNAME=$USERNAME" --env="LANG=$LANG" \
|
||||
--pidfile=$DIR/forgejo-runner-pid --errlog=$DIR/forgejo-runner.log --output=$DIR/forgejo-runner.log -- \
|
||||
forgejo-runner --config $FORGEJO_RUNNER_CONFIG daemon
|
||||
$DIR/forgejo-runner --config $FORGEJO_RUNNER_CONFIG daemon
|
||||
sleep 1
|
||||
cat $DIR/forgejo-runner.log
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ function setup() {
|
|||
dependencies
|
||||
if [[ "$version" =~ ^@ ]] ; then
|
||||
local branch=${version##@}
|
||||
build_runner $runner_repository $branch
|
||||
build_runner $runner_repository $branch $DIR
|
||||
else
|
||||
download $runner_repository $version
|
||||
fi
|
||||
|
@ -74,7 +74,9 @@ function setup() {
|
|||
|
||||
function teardown() {
|
||||
stop_daemon forgejo-runner $DIR
|
||||
rm -fr $(cat $DIR/forgejo-runner-home)
|
||||
if test -f $DIR/forgejo-runner-home ; then
|
||||
rm -fr $(cat $DIR/forgejo-runner-home)
|
||||
fi
|
||||
}
|
||||
|
||||
"$@"
|
||||
|
|
|
@ -10,7 +10,6 @@ source $SELF_DIR/forgejo-lib.sh
|
|||
: ${LOOP_DELAY:=5}
|
||||
WORKDIR=$(mktemp -d)
|
||||
: ${DIR:=$(pwd)}
|
||||
export DOT=$DIR
|
||||
|
||||
trap "rm -fr $WORKDIR" EXIT
|
||||
|
||||
|
|
Loading…
Reference in a new issue