Skip to content

Monitor Checks

Monitor Checks #21860

name: Monitor Checks
on:
schedule:
# Run every 30 minutes, as a fallback for cron-job.org activation (every 5min)
- cron: '*/30 * * * *'
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
jobs:
check-monitors:
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.commit.outputs.changes }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run monitor checks
run: node scripts/check-monitors.js
env:
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
- name: Commit and push updates
id: commit
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add data/history.json data/notification-state.json static/data/status.json
if git diff --staged --quiet; then
echo "changes=false" >> $GITHUB_OUTPUT
else
git commit -m "Update monitor status"
git push
echo "changes=true" >> $GITHUB_OUTPUT
fi
deploy:
needs: check-monitors
if: needs.check-monitors.outputs.changes == 'true'
uses: ./.github/workflows/deploy.yml