Run power outages monitor #3999
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run power outages monitor | |
| on: | |
| schedule: | |
| - cron: "*/10 * * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| monitor: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # token: ${{ secrets.PAT }} | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: ".nvmrc" | |
| - name: Install dependencies | |
| run: | | |
| npm install | |
| npx playwright install chromium | |
| - name: Run monitoring script | |
| env: | |
| # --- КИЇВСЬКА ОБЛАСТЬ --- | |
| # (Використовуємо старі секрети, але мапимо їх на нові змінні для monitor.js) | |
| CITY_KYIV: ${{ secrets.CITY }} | |
| STREET_KYIV: ${{ secrets.STREET }} | |
| HOUSE_KYIV: ${{ secrets.HOUSE }} | |
| # --- ОДЕСЬКА ОБЛАСТЬ --- | |
| # (Ці секрети треба додати в налаштуваннях репозиторію) | |
| CITY_ODESA: ${{ secrets.CITY_ODESA }} | |
| STREET_ODESA: ${{ secrets.STREET_ODESA }} | |
| HOUSE_ODESA: ${{ secrets.HOUSE_ODESA }} | |
| # --- ДНІПРОПЕТРОВСЬКА ОБЛАСТЬ --- | |
| # (Ці секрети треба додати в налаштуваннях репозиторію) | |
| CITY_DNIPRO: ${{ secrets.CITY_DNIPRO }} | |
| STREET_DNIPRO: ${{ secrets.STREET_DNIPRO }} | |
| HOUSE_DNIPRO: ${{ secrets.HOUSE_DNIPRO }} | |
| # --- CLOUDFLARE WORKER --- | |
| CF_WORKER_URL: ${{ secrets.CF_WORKER_URL }} | |
| CF_WORKER_TOKEN: ${{ secrets.CF_WORKER_TOKEN }} | |
| run: node ./src/monitor.js | |
| - name: Commit updated data | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| # Додаємо наш новий файл | |
| git add dtek.json artifacts/ | |
| # Перевіряємо, чи є зміни, щоб не робити пустих комітів | |
| if ! git diff --cached --quiet; then | |
| git commit -m "update: dtek data [skip ci]" | |
| git push | |
| else | |
| echo "No changes to commit" | |
| fi |