Skip to content

Check Status

Check Status #3078

Workflow file for this run

name: Check Status
on:
schedule:
- cron: '0 * * * *' # Every hour
workflow_dispatch: # Allows manual triggering
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check if the website is responding
id: check
run: |
status=$(curl -Is http://www.keays.xyz | head -n 1 | grep "200 OK" || echo "down")
echo "status=$status" >> $GITHUB_ENV
- name: Notify via SMS if website status
if: always() # Always run this step
env:
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }}
TWILIO_PHONE_NUMBER: ${{ secrets.TWILIO_PHONE_NUMBER }}
TO_PHONE_NUMBER: ${{ secrets.TO_PHONE_NUMBER }}
run: |
if [ "$status" = "down" ]; then
message="Website is down!"
else
message="Website is up and running."
fi
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/Messages.json" \
--data-urlencode "Body=$message" \
--data-urlencode "From=${TWILIO_PHONE_NUMBER}" \
--data-urlencode "To=${TO_PHONE_NUMBER}" \
-u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}"
- name: Notify via Pushover
if: always() # Always run this step
env:
PUSHOVER_USER_KEY: ${{ secrets.PUSHOVER_USER_KEY }}
PUSHOVER_API_TOKEN: ${{ secrets.PUSHOVER_API_TOKEN }}
run: |
if [ "$status" = "down" ]; then
message="Website is down!"
else
message="Website is up and running."
fi
curl -s \
--form-string "token=${PUSHOVER_API_TOKEN}" \
--form-string "user=${PUSHOVER_USER_KEY}" \
--form-string "message=${message}" \
https://api.pushover.net/1/messages.json