Skip to content

Commit

Permalink
feat: Perform action
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Aug 24, 2024
1 parent 9283fe3 commit d9ebac3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/automatic-instance-shelving.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
# Skip because instance status is being updated
continue
fi
# Extract issue number
issue_number=${instance_name##*-}
# Get instance IP
instance_ip=$(
openstack server show $instance_name -c addresses -f json | \
Expand All @@ -53,15 +55,23 @@ jobs:
exouser@$instance_ip \
'cat /proc/uptime | awk "{print \$1}"')
uptime_hours=$(echo "scale=2; $uptime_seconds / 3600" | bc)
# Check uptime
# Check uptime and define action
if $(python3 -c "valid=($uptime_hours > 3.5 and $uptime_hours <= 4.0); EXIT_SUCCESS=0; EXIT_FAILURE=1; exit(EXIT_SUCCESS if valid else EXIT_FAILURE)"); then
action="notify"
elif $(python3 -c "valid=($uptime_hours > 4.0); EXIT_SUCCESS=0; EXIT_FAILURE=1; exit(EXIT_SUCCESS if valid else EXIT_FAILURE)"); then
action="shelve"
else
action=""
fi
echo "instance_name [$instance_name], uptime_hours [$uptime_hours] -> action[$action]"
echo "instance_name [$instance_name], issue_number [$issue_number], uptime_hours [$uptime_hours] -> action[$action]"
# Perform action
if [[ "$action" == "shelve" ]]; then
gh issue comment $issue_number \
-b "/shelve<br>\
<br>\
_Command issues by *automatic-instance-shelving.yml* workflow. \
For details, see https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}_"
fi
done
env:
PREFIX: ${{ vars.INSTANCE_NAME_PREFIX }}

0 comments on commit d9ebac3

Please sign in to comment.