From 946c41cf4fd3f3092a783118550bb27bfd7514d4 Mon Sep 17 00:00:00 2001 From: Tomasz Duda Date: Tue, 13 Jun 2023 04:09:11 +0000 Subject: [PATCH] Improve `run.sh` to handle empty labels and log to stdout (#237) 1. Print logs on standard output 2. Don't add labels if GITEA_RUNNER_LABELS not set Reviewed-on: https://gitea.com/gitea/act_runner/pulls/237 Reviewed-by: Jason Song Co-authored-by: Tomasz Duda Co-committed-by: Tomasz Duda --- scripts/run.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index 8317b2d..d0154f0 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -10,6 +10,10 @@ CONFIG_ARG="" if [[ ! -z "${CONFIG_FILE}" ]]; then CONFIG_ARG="--config ${CONFIG_FILE}" fi +EXTRA_ARGS="" +if [[ ! -z "${GITEA_RUNNER_LABELS}" ]]; then + EXTRA_ARGS="${EXTRA_ARGS} --labels ${GITEA_RUNNER_LABELS}" +fi # Use the same ENV variable names as https://github.com/vegardit/docker-gitea-act-runner @@ -26,10 +30,7 @@ if [[ ! -s .runner ]]; then --instance "${GITEA_INSTANCE_URL}" \ --token "${GITEA_RUNNER_REGISTRATION_TOKEN}" \ --name "${GITEA_RUNNER_NAME:-`hostname`}" \ - --labels "${GITEA_RUNNER_LABELS}" \ - ${CONFIG_ARG} --no-interactive > /tmp/reg.log 2>&1 - - cat /tmp/reg.log + ${CONFIG_ARG} ${EXTRA_ARGS} --no-interactive 2>&1 | tee /tmp/reg.log cat /tmp/reg.log | grep 'Runner registered successfully' > /dev/null if [[ $? -eq 0 ]]; then