Add manual runner removal

Runners can now be manually removed using the CLI. Some restrictions apply:

  * A runner must be idle in github. Github will not allow us to remove a runner
that is running a workflow.
  * The runner status must be "running"

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2022-06-29 16:23:01 +00:00
parent 1f419d0abc
commit 5390efbaab
20 changed files with 336 additions and 120 deletions

View file

@ -24,7 +24,8 @@ function sendStatus() {
function success() {
MSG="$1"
call "{\"status\": \"idle\", \"message\": \"$MSG\"}"
ID=$2
call "{\"status\": \"idle\", \"message\": \"$MSG\", \"agent_id\": $ID}"
}
function fail() {
@ -57,5 +58,11 @@ sendStatus "installing runner service"
sendStatus "starting service"
./svc.sh start || fail "failed to start service"
success "runner successfully installed"
set +e
AGENT_ID=$(grep "agentId" /home/{{ .RunnerUsername }}/actions-runner/.runner | tr -d -c 0-9)
if [ $? -ne 0 ];then
fail "failed to get agent ID"
fi
set -e
success "runner successfully installed" $AGENT_ID

View file

@ -24,7 +24,8 @@ function sendStatus() {
function success() {
MSG="$1"
call "{\"status\": \"idle\", \"message\": \"$MSG\"}"
ID=$2
call "{\"status\": \"idle\", \"message\": \"$MSG\", \"agent_id\": $ID}"
}
function fail() {
@ -57,5 +58,11 @@ sendStatus "installing runner service"
sendStatus "starting service"
./svc.sh start || fail "failed to start service"
success "runner successfully installed"
set +e
AGENT_ID=$(grep "agentId" /home/{{ .RunnerUsername }}/actions-runner/.runner | tr -d -c 0-9)
if [ $? -ne 0 ];then
fail "failed to get agent ID"
fi
set -e
success "runner successfully installed" $AGENT_ID