Skip to content

Commit d9ebac3

Browse files
committed
feat: Perform action
1 parent 9283fe3 commit d9ebac3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/workflows/automatic-instance-shelving.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535
# Skip because instance status is being updated
3636
continue
3737
fi
38+
# Extract issue number
39+
issue_number=${instance_name##*-}
3840
# Get instance IP
3941
instance_ip=$(
4042
openstack server show $instance_name -c addresses -f json | \
@@ -53,15 +55,23 @@ jobs:
5355
exouser@$instance_ip \
5456
'cat /proc/uptime | awk "{print \$1}"')
5557
uptime_hours=$(echo "scale=2; $uptime_seconds / 3600" | bc)
56-
# Check uptime
58+
# Check uptime and define action
5759
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
5860
action="notify"
5961
elif $(python3 -c "valid=($uptime_hours > 4.0); EXIT_SUCCESS=0; EXIT_FAILURE=1; exit(EXIT_SUCCESS if valid else EXIT_FAILURE)"); then
6062
action="shelve"
6163
else
6264
action=""
6365
fi
64-
echo "instance_name [$instance_name], uptime_hours [$uptime_hours] -> action[$action]"
66+
echo "instance_name [$instance_name], issue_number [$issue_number], uptime_hours [$uptime_hours] -> action[$action]"
67+
# Perform action
68+
if [[ "$action" == "shelve" ]]; then
69+
gh issue comment $issue_number \
70+
-b "/shelve<br>\
71+
<br>\
72+
_Command issues by *automatic-instance-shelving.yml* workflow. \
73+
For details, see https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}_"
74+
fi
6575
done
6676
env:
6777
PREFIX: ${{ vars.INSTANCE_NAME_PREFIX }}

0 commit comments

Comments
 (0)