Skip to content

Commit

Permalink
Another attempt to fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisameling committed Sep 15, 2024
1 parent 070a161 commit 300182d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/cleanup-self-hosted-runners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ jobs:
for active_vm in ${active_vms[@]}; do
vm_name=$(echo $active_vm | jq '.name')
vm_creation_iso_string=$(echo $active_vm | jq -r '.timeCreated')
# Bash's date -d command doesn't support the full ISO 8601 format with milliseconds and timezone, so let's strip those
vm_creation_trimmed=$(echo "$vm_creation_iso_string" | sed 's/\.[0-9]*//;s/+[^+]*$//')
vm_creation_time=$(TZ=UTC date -d $vm_creation_trimmed +%s)
# Use jq to extract and format the date-time string
vm_creation_time_string=$(echo $active_vm | jq -r '.timeCreated | sub("\\.[0-9]+[+-][0-9]+:[0-9]+$"; "") | sub("T"; " ")')
vm_creation_time=$(TZ=UTC date -d $vm_creation_time_string +%s)
if [ "$one_hour_ago" -lt "$vm_creation_time" ]; then
echo "::notice::The VM ${vm_name} was created less then 1 hour ago and shouldn't be deleted yet. Skipping."
Expand Down

0 comments on commit 300182d

Please sign in to comment.