Skip to content

Website Monitor & Auto-Rollback #23

Website Monitor & Auto-Rollback

Website Monitor & Auto-Rollback #23

Workflow file for this run

name: Website Monitor & Auto-Rollback
on:
schedule:
- cron: '*/15 * * * *' # every 15 minutes
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
outputs:
status: ${{ steps.health.outputs.status }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check website health
id: health
run: |
SITE="https://acreetionos.org"
HTTP_CODE=$(curl -sI -o /dev/null -w "%{http_code}" --max-time 15 "$SITE" 2>/dev/null || echo "000")
echo "HTTP Status: $HTTP_CODE"
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "301" ] || [ "$HTTP_CODE" = "302" ]; then
CONTENT_CHECK=$(curl -sL --max-time 15 "$SITE" 2>/dev/null | grep -c "AcreetionOS" || echo "0")
if [ "$CONTENT_CHECK" -gt 0 ]; then
echo "status=healthy" >> $GITHUB_OUTPUT
echo "✓ Website is UP — serving correctly"
echo "✓ Site healthy" >> $GITHUB_STEP_SUMMARY
exit 0
fi
fi
echo "status=down" >> $GITHUB_OUTPUT
echo "✗ Website is DOWN or returning errors" >> $GITHUB_STEP_SUMMARY
- name: Check subdomains
if: steps.health.outputs.status == 'healthy'
run: |
for sub in "wiki" "blog" "immutable" "gitlab"; do
CODE=$(curl -sI -o /dev/null -w "%{http_code}" --max-time 10 "https://$sub.acreetionos.org" 2>/dev/null || echo "000")
STATUS="✓"
[ "$CODE" = "200" ] || [ "$CODE" = "301" ] || [ "$CODE" = "302" ] || STATUS="✗"
echo "$STATUS $sub.acreetionos.org → HTTP $CODE"
done
rollback:
needs: check
if: needs.check.outputs.status == 'down'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 50
- name: Find last known good commit
run: |
echo "Site is down. Finding last good commit..."
for i in $(seq 1 20); do
COMMIT=$(git log --skip=$i --oneline -1 --format="%H" 2>/dev/null || echo "")
[ -z "$COMMIT" ] && break
echo "Testing commit $COMMIT..."
# We can't actually deploy old commits directly, but we can revert
done
# Revert the most recent commit
echo "Reverting last commit..."
git revert --no-edit HEAD 2>&1 || echo "Revert failed — trying reset"
echo "Rollback initiated" >> $GITHUB_STEP_SUMMARY
- name: Force push rollback
run: |
git push --force-with-lease 2>&1 || echo "Push failed — manual intervention required"
echo "✓ Rollback deployed" >> $GITHUB_STEP_SUMMARY
report:
needs: [check, rollback]
if: always()
runs-on: ubuntu-latest
steps:
- name: Report status
run: |
STATUS="${{ needs.check.outputs.status }}"
if [ "$STATUS" = "healthy" ]; then
echo "✅ All systems operational" >> $GITHUB_STEP_SUMMARY
else
echo "⚠ Rollback was triggered" >> $GITHUB_STEP_SUMMARY
fi