Update monitor.yml

This commit is contained in:
dvirlabs 2025-06-27 18:05:23 +03:00
parent 368291eb2d
commit c385b98982

View File

@ -2,35 +2,33 @@ name: Monitor Lab URLs
on: on:
schedule: schedule:
- cron: "*/5 * * * *" # מריץ כל 5 דקות (שנה לפי הצורך) - cron: "*/5 * * * *" # כל 5 דקות
workflow_dispatch: workflow_dispatch:
jobs: jobs:
monitor: monitor:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check Woodpecker URL - name: Check services
run: | run: |
URL="https://woodpecker.dvirlabs.com" check_url() {
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$URL") URL=$1
TIME=$(date "+%Y-%m-%d %H:%M:%S") NAME=$2
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
TIME=$(date "+%Y-%m-%d %H:%M:%S")
if [[ "$STATUS" == "502" ]]; then if [[ "$STATUS" == "502" || "$STATUS" == "404" ]]; then
curl -s \ curl -s \
--form-string "token=${{ secrets.PUSHOVER_TOKEN }}" \ --form-string "token=${{ secrets.PUSHOVER_TOKEN }}" \
--form-string "user=${{ secrets.PUSHOVER_USER }}" \ --form-string "user=${{ secrets.PUSHOVER_USER }}" \
--form-string "title=🚨 Woodpecker Alert" \ --form-string "title=🔴 $NAME Alert" \
--form-string "message=⚠️ $URL is down (502) at $TIME" \ --form-string "message=⚠️ $URL is down ($STATUS) at $TIME" \
https://api.pushover.net/1/messages.json https://api.pushover.net/1/messages.json
exit 1 else
elif [[ "$STATUS" == "404" ]]; then echo "✅ $NAME is up: $STATUS"
curl -s \ fi
--form-string "token=${{ secrets.PUSHOVER_TOKEN }}" \ }
--form-string "user=${{ secrets.PUSHOVER_USER }}" \
--form-string "title=🚨 Woodpecker Alert" \ check_url "https://woodpecker.dvirlabs.com" "Woodpecker"
--form-string "message=❌ $URL returned 404 at $TIME" \ check_url "https://grafana.dvirlabs.com" "Grafana"
https://api.pushover.net/1/messages.json check_url "https://vault.dvirlabs.com" "Vault"
exit 1
else
echo "✅ Woodpecker is up: $STATUS"
fi