Skip to content

Website Status Check #4322

Website Status Check

Website Status Check #4322

name: Website Status Check
on:
schedule:
- cron: '*/30 * * * *' # Runs every 30 minutes
workflow_dispatch: # Allows manual triggering
jobs:
check_website:
runs-on: ubuntu-latest
steps:
- name: Check website status
run: |
if curl -sSf https://django-appt-doc.adamspierredavid.com > /dev/null; then
echo "STATUS=up" >> $GITHUB_ENV
echo "COLOR=brightgreen" >> $GITHUB_ENV
else
echo "STATUS=down" >> $GITHUB_ENV
echo "COLOR=red" >> $GITHUB_ENV
fi
- name: Update Gist
env:
GIST_ID: ${{ secrets.GIST_ID }}
GH_TOKEN: ${{ secrets.GIST_SECRET }}
run: |
GIST_CONTENT=$(cat << EOF
{
"schemaVersion": 1,
"label": "django-appointment docs",
"message": "${{ env.STATUS }}",
"color": "${{ env.COLOR }}",
"isError": ${{ env.STATUS == 'down' }},
"namedLogo": "django"
}
EOF
)
RESPONSE=$(curl -s -X PATCH \
-H "Authorization: token $GH_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"files\": {\"django-appointment-doc-status.json\": {\"content\": $(echo $GIST_CONTENT | jq -R -s '.')}}}" \
"https://api.github.com/gists/$GIST_ID")
echo "Gist update response:"
echo "$RESPONSE" | jq '.'
if echo "$RESPONSE" | jq -e '.files."django-appointment-doc-status.json"' > /dev/null; then
echo "Gist updated successfully"
else
echo "Failed to update gist"
exit 1
fi