Skip to content

Commit e570fa6

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

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
# Skip because instance status is being updated
3636
continue
3737
fi
38+
# Extract issue number
39+
issue_number=${instance_name##*-}
40+
echo "issue_number [$issue_number]"
3841
# Get instance IP
3942
instance_ip=$(
4043
openstack server show $instance_name -c addresses -f json | \
@@ -53,7 +56,7 @@ jobs:
5356
exouser@$instance_ip \
5457
'cat /proc/uptime | awk "{print \$1}"')
5558
uptime_hours=$(echo "scale=2; $uptime_seconds / 3600" | bc)
56-
# Check uptime
59+
# Check uptime and define action
5760
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
5861
action="notify"
5962
elif $(python3 -c "valid=($uptime_hours > 4.0); EXIT_SUCCESS=0; EXIT_FAILURE=1; exit(EXIT_SUCCESS if valid else EXIT_FAILURE)"); then
@@ -62,6 +65,17 @@ jobs:
6265
action=""
6366
fi
6467
echo "instance_name [$instance_name], uptime_hours [$uptime_hours] -> action[$action]"
68+
# Perform action
69+
if [[ "$action" == "shelve" ]]; then
70+
gh issue comment $issue_number \
71+
-b "/shelve<br>\
72+
<br>\
73+
_Command issues by *automatic-instance-shelving.yml* workflow. \
74+
For details, see https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}_"
75+
fi
6576
done
6677
env:
78+
env:
79+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
GH_REPO: ${{ github.repository }}
6781
PREFIX: ${{ vars.INSTANCE_NAME_PREFIX }}

0 commit comments

Comments
 (0)