Skip to content

Commit

Permalink
separate the configuration for self-hosted runners into privileged an…
Browse files Browse the repository at this point in the history
…d unprivileged
  • Loading branch information
k-rister committed Oct 1, 2024
1 parent a8879e2 commit 1b6e809
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 17 deletions.
File renamed without changes.
4 changes: 4 additions & 0 deletions .github/runners/self-hosted/unprivileged/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LANG=en_US.UTF-8

ACTIONS_RUNNER_HOOK_JOB_STARTED=/home/manager/actions-runner-hooks/job-started.sh
ACTIONS_RUNNER_HOOK_JOB_COMPLETED=/home/manager/actions-runner-hooks/job-completed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# cleanup the workspace
if [ -n "${GITHUB_WORKSPACE}" ]; then
if pushd "${GITHUB_WORKSPACE}"; then
echo "Cleaning up..."
find ! -name '.' ! -name '..' -delete
echo "...cleanup complete"

popd
else
echo "ERROR: Failed to pushd to '${GITHUB_WORKSPACE}'"
exit 1
fi
else
echo "ERROR: GITHUB_WORKSPACE is not defined"
exit 1
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# cleanup the workspace
if [ -n "${GITHUB_WORKSPACE}" ]; then
if pushd "${GITHUB_WORKSPACE}"; then
echo "Cleaning up..."
find ! -name '.' ! -name '..' -delete
echo "...cleanup complete"

popd
else
echo "ERROR: Failed to pushd to '${GITHUB_WORKSPACE}'"
exit 1
fi
else
echo "ERROR: GITHUB_WORKSPACE is not defined"
exit 1
fi
46 changes: 29 additions & 17 deletions .github/runners/self-hosted/update-runners.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,40 @@ pushd $(dirname $0) > /dev/null

runner_user="manager"

if [ ! -e runners.conf ]; then
echo "ERROR: Could not find runners.conf"
exit 1
fi
for runner_type in "privileged" "unprivileged"; do
if pushd ${runner_type}; then
echo "runner_type=${runner_type}"

for runner_ip in $(cat runners.conf); do
echo "runner_ip=${runner_ip}"
if [ ! -e runners.conf ]; then
echo "ERROR: Could not find runners.conf"
exit 1
fi

echo "syncing actions-runner-hooks:"
rsync -av --progress --stats --delete actions-runner-hooks ${runner_user}@${runner_ip}:
for runner_ip in $(cat runners.conf); do
echo "runner_ip=${runner_ip}"

echo "listing actions-runner-hooks:"
ssh ${runner_user}@${runner_ip} "ls -l ~/actions-runner-hooks"
echo "syncing actions-runner-hooks:"
rsync -av --progress --stats --delete actions-runner-hooks ${runner_user}@${runner_ip}:

echo "synching .env:"
rsync -av --progress --stats .env ${runner_user}@${runner_ip}:~/actions-runner/.env
echo "listing actions-runner-hooks:"
ssh ${runner_user}@${runner_ip} "ls -l ~/actions-runner-hooks"

echo "displaying .env:"
ssh ${runner_user}@${runner_ip} "cat ~/actions-runner/.env"
echo "synching .env:"
rsync -av --progress --stats .env ${runner_user}@${runner_ip}:~/actions-runner/.env

echo "restarting the runner:"
ssh ${runner_user}@${runner_ip} "sudo reboot"
echo "displaying .env:"
ssh ${runner_user}@${runner_ip} "cat ~/actions-runner/.env"

echo "##########################################################"
echo "restarting the runner:"
ssh ${runner_user}@${runner_ip} "sudo reboot"

echo "##########################################################"
done

popd

echo "**********************************************************"
else
echo "ERROR: Failed to pushd to ${runner_type}"
fi
done

0 comments on commit 1b6e809

Please sign in to comment.