2
0
Fork 0
rootfs/usr/local/bin/sh.zio.github-runner-wrapper

44 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
_PLUG_TITLE="GitHub Runner Wrapper"
_PLUG_DESCRIPTION=""
_PLUG_ARGS=(
"token;t;;string"
"url;u;;string"
"ex-version;;;string;2.311.0"
"ex-version-arch;;;string;x64"
)
_PLUG_POSITIONAL="url token"
function main() {
identifier="$(echo $_url | sed -e "s|https://github.com/||" -e "s|/|.|g")"
gh_runner_dir="$HOME/.local/bin/gh-runner_$identifier"
download_path="https://github.com/actions/runner/releases/download/v$_ex_version/actions-runner-linux-$_ex_version_arch-$_ex_version.tar.gz"
mkdir -p "$gh_runner_dir"
cd "$gh_runner_dir"
if [ -z "$(ls -A $gh_runner_dir)" ]; then
curl -o "actions-runner-linux-$_ex_version.tar.gz" -L "$download_path"
tar xzf "actions-runner-linux-$_ex_version.tar.gz"
rm "actions-runner-linux-$_ex_version.tar.gz"
fi
if [[ ! -f ".credentials" ]]; then
./config.sh --url "$url" --token "$token" --unattended
fi
./run.sh
}
if [[ $_PLUG_INVOKED != "true" ]]; then
base_dir="$(dirname "$(realpath -s "$0")")"
git_dir="$base_dir/../../.."
if [[ -d "$git_dir/.git" ]]; then
"$git_dir/usr/local/libexec/sodalite/invoker/src/invoke.sh" "$0" $@
else
"/usr/local/libexec/sodalite/invoker/src/invoke.sh" "$0" $@
fi
fi