Skip to content

validate self-hosted runner status #5

validate self-hosted runner status

validate self-hosted runner status #5

---
# TODO: ipatch, the problem self-hosted runner will remove from github if it doesn't connect to
# github with 14 days.
# 1. need a way to verify remote box is online ie. archbox aka mbp
# 2. once remote box is online, check to see if vm serice ie. vmmojave is up and running.
# a. status the systemd service for the vm
# b. ping the vm by its static ip address and see if i get a response
# c.
# 3. check if the runner is online, the runner should be started as a service
# a. this can be done by querying api.github.com/[OWNER/REPO]...
#
# 1. so there needs to be a way check the status of the runner and record that timestamp so when that
# time expires we need to run through our check to make sure our runner is online.
# 2. if one of our checks fails we need to send an email followed by an action / step to try
# and bring the service online, and then move to the next step.
# the way of thinking of this is to,
# 1 .first check if the runner is online
# a. query the api endpoint
# a1. if getting a successful online respone from api take note, and begin timer,
# ...and then set a timer for 12 days to query runner again.
# a1a. next, need to hash steps if the runner is not online.
name: validate self-hosted runner status
on:
# NOTE: run this action on request from github web UI
workflow_dispatch:
schedule:
# min hour day month day-of-week,1-6 contrab.guru
- cron: '1 4 */12 * *' # run task every 12 days
jobs:
validate-self-hosted-runner:
# TODO: what is the quickest github-hosted runner that can boot up?
runs-on: ubuntu-latest
steps:
- name: Configure SSH for github hosted runner
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/shrunserver.key
chmod 600 ~/.ssh/shrunserver.key
cat >>~/.ssh/config <<END
Host shrunserver
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/shrunserver.key
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.ARCHBOX_SERVER_USER }}
SSH_KEY: ${{ secrets.ACTIONS_SSH_PRIVATE_KEY }}
SSH_HOST: ${{ secrets.ARCHBOX_SERVER_IP }}
# NOTE: HOMEBREW_GITHUB_API_TOKEN needed in repo secrets, use web UI
- name: check the status of the vmmojave self-hosted runner for freecad/homebrew-freecad
run: |
status_selfhosted_vmmojave=\
$(curl -s -H "Authorization: Bearer ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}" \
https://api.github.com/repos/freecad/homebrew-freecad/actions/runners \
| jq -r '.runners[] | select(.name == "vmmojave") | .status')
if [[ "$status_selfhosted_vmmojave" == "online" ]]; then
echo "Runner is online ✅"
# TODO: peform additional actions
else
# Check if the machine is reachable
if nc -v -z -w 5 "${{ secrets.ARCHBOX_SERVER_IP }}" 22; then
echo "Machine hosting the runner is online ✅"
# NOTE: ipatch, attempt to run command on remote computer via ssh
ssh shrunserver 'date'
if ssh shrunserver 'nc -v -z -w 5 192.168.1.114 22'; then
# nc -v -z -w 5 192.168.1.114 22
echo "vmmojave appears to be online"
# TODO: need to figure out how to nest ssh ie. login to linux server then login to vmmojave
# TODO: attempt to start github runner
else
echo "could not reach vmmojave self-hosted runner"
fi
else
echo "Machine hosting the runner is NOT online!"
fi
fi