Improvements

Signed-off-by: Igor <igor@armbian.com>
This commit is contained in:
Igor
2023-04-19 13:20:27 +02:00
parent a2ea155db9
commit eb09c4df7a
2 changed files with 50 additions and 2 deletions

View File

@@ -51,4 +51,42 @@ runs:
hcloud server delete $(hcloud server list --output columns=id,name | grep ${machinename} | cut -d" " -f1)
i=$(( i + 1 ))
[[ $i == ${{ inputs.machine-count }} ]] && break
done
done
- name: Remove runners
env:
GH_TOKEN: ${{ inputs.github_token }}
shell: bash
run: |
# for some reason last added doesn't show up
#RUNNERS=$(gh api \
#-H "Accept: application/vnd.github+json" \
#-H "X-GitHub-Api-Version: 2022-11-28" \
#"/orgs/${{ github.repository_owner }}/actions/runners?per_page=1000" | \
#jq -r '.runners[] | select(.labels[].name=="temp")' | jq '.id')
# get all runners that have label "temp"
RUNNERS=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${{ github.repository_owner }}/os/actions/runners?per_page=1000" | \
jq -r '.runners[] | select(.labels[].name=="temp")' | jq '.id')
# remove them
# while IFS= read -r id; do
#gh api \
#--method DELETE \
#-H "Accept: application/vnd.github+json" \
#-H "X-GitHub-Api-Version: 2022-11-28" \
#/orgs/${{ github.repository_owner }}/actions/runners/${id}
#done <<< $RUNNERS
# remove them
while IFS= read -r id; do
gh api \
--method DELETE \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository_owner }}/os/actions/runners/${id}
done <<< $RUNNERS

View File

@@ -51,8 +51,18 @@ runs:
machinenames=("Faerie" "November" "Raven" "Hammer" "Foxtrot" "Papa" "Chimera" "Panther")
for machinename in "${machinenames[@]}"
do
hcloud server delete $(hcloud server list --output columns=id,name | grep ${machinename} | cut -d" " -f1) || true
hcloud server create --name ${machinename} --image ubuntu-22.04 --type ${{ inputs.machine-type }} --ssh-key TORRENT
sleep 30
i=$(( i + 1 ))
[[ $i == ${{ inputs.machine-count }} ]] && break
done
# make sure all are up
sleep 20
i=0
for machinename in "${machinenames[@]}"
do
IP=$(hcloud server list --output columns=ipv4,name | grep ${machinename} | cut -d" " -f1)
ssh-keygen -f "$HOME/.ssh/known_hosts" -R "${IP}" || true
ssh -o StrictHostKeyChecking=no root@${IP} "export STOP=${{ inputs.runners-count}} NAME=${machinename} GH_TOKEN=${{ env.GH_TOKEN }}; $COMMAND"