Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Armbian runners deploy: fixing bugs #369

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions tools/modules/system/module_armbian_runners.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ function module_armbian_runners () {
local owner="${owner}"
local repository="${repository}"

# workaround. Remove when parameters handling is fixed
local label_primary=$(echo $label_primary | sed "s/_/,/g") # convert
local label_secondary=$(echo $label_secondary | sed "s/_/,/g") # convert

# we can generate per org or per repo
local registration_url="${organisation}"
local prefix="orgs"
Expand Down Expand Up @@ -82,7 +86,7 @@ function module_armbian_runners () {
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/${prefix}/${registration_url}/actions/runners/registration-token | jq -r .token)

${module_options["module_armbian_runners,feature"]} ${commands[1]} ${runner_name}
${module_options["module_armbian_runners,feature"]} ${commands[1]} ${runner_name} "${i}"

adduser --quiet --disabled-password --shell /bin/bash \
--home /home/actions-runner-${i} --gecos "actions-runner-${i}" actions-runner-${i}
Expand Down Expand Up @@ -114,19 +118,17 @@ function module_armbian_runners () {
;;
"${commands[1]}")
# delete if previous already exists
if id "actions-runner-${i}" >/dev/null 2>&1; then
echo "Removing runner ${i} on GitHub"
${module_options["module_armbian_runners,feature"]} ${commands[2]} "$2-${i}"
echo "Removing runner ${i} locally"
runner_home=$(getent passwd "actions-runner-${i}" | cut -d: -f6)
if [[ -f "${runner_home}/svc.sh" ]]; then
sh -c "cd ${runner_home} ; sudo ./svc.sh stop actions-runner-${i} >/dev/null; sudo ./svc.sh uninstall actions-runner-${i} >/dev/null"
fi
userdel -r -f actions-runner-${i} 2>/dev/null
groupdel actions-runner-${i} 2>/dev/null
sed -i "/^actions-runner-${i}.*/d" /etc/sudoers
rm -rf "${runner_home}"
echo "Removing runner $3 on GitHub"
${module_options["module_armbian_runners,feature"]} ${commands[2]} "$2-$3"
echo "Removing runner $3 locally"
runner_home=$(getent passwd "actions-runner-${3}" | cut -d: -f6)
if [[ -f "${runner_home}/svc.sh" ]]; then
sh -c "cd ${runner_home} ; sudo ./svc.sh stop actions-runner-$3 >/dev/null; sudo ./svc.sh uninstall actions-runner-$3 >/dev/null"
fi
userdel -r -f actions-runner-$3 2>/dev/null
groupdel actions-runner-$3 2>/dev/null
sed -i "/^actions-runner-$3.*/d" /etc/sudoers
[[ ${runner_home} != "/" ]] && rm -rf "${runner_home}"
;;
"${commands[2]}")
DELETE=$2
Expand Down
Loading