Skip to content

Run main.py every 15 minutes #6609

Run main.py every 15 minutes

Run main.py every 15 minutes #6609

Workflow file for this run

name: Run main.py every 15 minutes
on:
schedule:
- cron: "*/15 * * * *"
workflow_dispatch:
permissions:
contents: write # nécessaire pour pousser la DB
concurrency:
group: traffic-logging
cancel-in-progress: true # évite les overlaps
jobs:
run-script:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
# Cache des navigateurs Playwright (version Python)
- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-msplaywright-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-msplaywright-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install playwright
# IMPORTANT : installer les navigateurs pour Playwright **Python**
- name: Install Playwright browsers (Python)
run: |
python -m playwright install chromium --with-deps
- name: Run main.py (headless)
env:
# Pas besoin de DISPLAY si vous lancez headless=True dans votre code
PYTHONUNBUFFERED: "1"
run: python main.py
# Optionnel : pousser la base SQLite mise à jour
- name: Commit and push updated DB
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add data/traffic_logs.db || true
git commit -m "Automated update of traffic_logs.db at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" || echo "No changes to commit"
git push origin ${{ github.ref }} || echo "No changes to push"