mirror of
https://github.com/hanzoai/docker-github-actions-runner.git
synced 2026-09-30 21:42:55 +00:00
39 lines
975 B
Bash
39 lines
975 B
Bash
#!/bin/bash
|
|
|
|
export RUNNER_ALLOW_RUNASROOT=1
|
|
export PATH=$PATH:/actions-runner
|
|
|
|
deregister_runner() {
|
|
echo "Caught SIGTERM. Deregistering runner"
|
|
_TOKEN=$(bash /token.sh)
|
|
RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
|
|
./config.sh remove --token "${RUNNER_TOKEN}"
|
|
exit
|
|
}
|
|
|
|
_RUNNER_NAME=${RUNNER_NAME:-${RUNNER_NAME_PREFIX:-github-runner}-$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')}
|
|
_RUNNER_WORKDIR=${RUNNER_WORKDIR:-/_work}
|
|
_LABELS=${LABELS:-default}
|
|
_SHORT_URL=${REPO_URL}
|
|
|
|
if [[ -n "${ACCESS_TOKEN}" ]]; then
|
|
_TOKEN=$(bash /token.sh)
|
|
RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
|
|
_SHORT_URL=$(echo "${_TOKEN}" | jq -r .short_url)
|
|
fi
|
|
|
|
echo "Configuring"
|
|
./config.sh \
|
|
--url "${_SHORT_URL}" \
|
|
--token "${RUNNER_TOKEN}" \
|
|
--name "${_RUNNER_NAME}" \
|
|
--work "${_RUNNER_WORKDIR}" \
|
|
--labels "${_LABELS}" \
|
|
--unattended \
|
|
--replace
|
|
|
|
unset RUNNER_TOKEN
|
|
trap deregister_runner SIGINT SIGQUIT SIGTERM
|
|
|
|
./bin/runsvc.sh
|