2023-12-03 03:33:53 +01:00
|
|
|
#!/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
|
|
|
|
|
2023-12-03 03:41:38 +01:00
|
|
|
export RUNNER_ALLOW_RUNASROOT="1"
|
|
|
|
|
2023-12-03 03:33:53 +01:00
|
|
|
if [[ ! -f ".credentials" ]]; then
|
2023-12-03 03:43:24 +01:00
|
|
|
./config.sh --url "$_url" --token "$_token" --unattended
|
2023-12-03 03:33:53 +01:00
|
|
|
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
|