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 e570fa6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion .github/workflows/automatic-instance-shelving.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
# Skip because instance status is being updated
continue
fi
# Extract issue number
issue_number=${instance_name##*-}
echo "issue_number [$issue_number]"
# Get instance IP
instance_ip=$(
openstack server show $instance_name -c addresses -f json | \
Expand All @@ -53,7 +56,7 @@ 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
Expand All @@ -62,6 +65,17 @@ jobs:
action=""
fi
echo "instance_name [$instance_name], 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:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PREFIX: ${{ vars.INSTANCE_NAME_PREFIX }}

0 comments on commit e570fa6

Please sign in to comment.