ci: runner config

This commit is contained in:
Denis Gukov 2023-09-13 10:36:04 +02:00
parent d8826b7453
commit 2b8e1c363f

View File

@ -5,39 +5,25 @@ set -e
echoerr() { printf "%s\n" "$*" >&2; }
SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}"
SEMAPHORE_TMP_PATH="${SEMAPHORE_TMP_PATH:-/tmp/semaphore}"
SEMAPHORE_REGISTRATION_TOKEN="${SEMAPHORE_TMP_PATH:-/tmp/semaphore}"
SEMAPHORE_RUNNER_CONFIG_FILE="${SEMAPHORE_TMP_PATH:-/tmp/semaphore-runner.json}"
SEMAPHORE_API_URL="${SEMAPHORE_TMP_PATH:-http://localhost:3000/api}"
[ -d "${SEMAPHORE_TMP_PATH}" ] || mkdir -p "${SEMAPHORE_TMP_PATH}" || {
echo "Can't create Semaphore tmp path ${SEMAPHORE_TMP_PATH}."
exit 1
}
[ -d "${SEMAPHORE_CONFIG_PATH}" ] || mkdir -p "${SEMAPHORE_CONFIG_PATH}" || {
echo "Can't create Semaphore Config path ${SEMAPHORE_CONFIG_PATH}."
exit 1
}
SEMAPHORE_REGISTRATION_TOKEN="${SEMAPHORE_REGISTRATION_TOKEN:-}"
SEMAPHORE_API_URL="${SEMAPHORE_API_URL:-}"
# Create a config if it does not exist in the current config path
if [ ! -f "${SEMAPHORE_CONFIG_PATH}/config.json" ]; then
echoerr "Generating ${SEMAPHORE_CONFIG_PATH}/config.json ..."
if [ ! -f "/etc/semaphore/config.json" ]; then
echoerr "Generating /etc/semaphore/config.json ..."
cat << EOF > "${SEMAPHORE_CONFIG_PATH}/config.json"
cat << EOF > "/etc/semaphore/config.json"
{
"tmp_path": "${SEMAPHORE_TMP_PATH}",
"tmp_path": "/data",
"runner": {
"registration_token": "${SEMAPHORE_REGISTRATION_TOKEN}",
"config_file": "${SEMAPHORE_RUNNER_CONFIG_FILE}",
"config_file": "/data/runner.json",
"api_url": "${SEMAPHORE_API_URL}"
}
}
EOF
echoerr "Run Semaphore with semaphore --config ${SEMAPHORE_CONFIG_PATH}/config.json"
echoerr "Run Semaphore with semaphore --config /etc/semaphore/config.json"
fi
# run our command