Skip to content

Synthetic Monitoring #946

Synthetic Monitoring

Synthetic Monitoring #946

name: Synthetic Monitoring
on:
schedule:
# Run 4 times daily (every 6 hours) to conserve runner minutes
- cron: '0 */6 * * *'
workflow_dispatch: # Allow manual trigger
permissions:
contents: read
env:
PRODUCTION_URL: ${{ secrets.PRODUCTION_URL }}
jobs:
health-check:
runs-on: [self-hosted, macOS]
timeout-minutes: 5
steps:
- name: Health Endpoint Check
id: health
continue-on-error: true
run: |
if [ -z "${{ env.PRODUCTION_URL }}" ]; then
echo "::warning::PRODUCTION_URL is not set. Skipping checks."
exit 0
fi
response=$(curl -s -o response.json -w "%{http_code}" "${{ env.PRODUCTION_URL }}/health" || true)
echo "status_code=$response" >> $GITHUB_OUTPUT
if [ "$response" != "200" ]; then
echo "::error::Health check failed with status code: $response"
exit 1
fi
echo "βœ… Health check passed"
cat response.json
- name: API Docs Check
continue-on-error: true
run: |
response=$(curl -s -o /dev/null -w "%{http_code}" "${{ env.PRODUCTION_URL }}/api-docs" || true)
if [ "$response" != "200" ]; then
echo "::error::API docs check failed with status code: $response"
exit 1
fi
echo "βœ… API docs accessible"
- name: Homepage SSR Check
continue-on-error: true
run: |
response=$(curl -s -o /dev/null -w "%{http_code}" "${{ env.PRODUCTION_URL }}/" || true)
if [ "$response" != "200" ]; then
echo "::error::Homepage check failed with status code: $response"
exit 1
fi
echo "βœ… Homepage SSR working"
- name: Products Page Check
continue-on-error: true
run: |
response=$(curl -s -o /dev/null -w "%{http_code}" "${{ env.PRODUCTION_URL }}/products" || true)
if [ "$response" != "200" ]; then
echo "::error::Products page check failed with status code: $response"
exit 1
fi
echo "βœ… Products page working"
notify-on-failure:
needs: health-check
if: failure()
runs-on: [self-hosted, macOS]
steps:
- name: Send Alert
run: |
echo "::error::Synthetic monitoring detected service issues!"
echo "Time: $(date -u)"
echo "Check the health-check job for details."
# Uncomment and configure if using Slack notifications
# curl -X POST -H 'Content-type: application/json' \
# --data '{"text":"🚨 RUN Apparel synthetic monitoring detected issues!"}' \
# ${{ secrets.SLACK_WEBHOOK_URL }}