Spaces:
Running
Running
| # This fetches and updates the historical data pool daily | |
| name: Fetch Daily AQI Data | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '10 5,11,17,23 * * *' | |
| jobs: | |
| build-and-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run data processing pipeline | |
| # This 'set -e' is critical. It forces the workflow to stop | |
| # the moment any of your Python scripts exit with an error. --@Qamar | |
| shell: bash | |
| run: | | |
| set -e | |
| echo "--- Running: fetch_current_data.py ---" | |
| python fetch_current_data.py | |
| echo "--- Running: hourly_to_daily.py ---" | |
| python hourly_to_daily.py | |
| echo "--- Running: append_and_clean_historical_data.py ---" | |
| python append_and_clean_historical_data.py | |
| - name: Verify script outputs | |
| run: | | |
| echo "--- Verifying file contents ---" | |
| echo "--- last_7_days_daily_data.csv (head) ---" | |
| head -n 5 data/last_7_days_daily_data.csv | |
| echo "--- karachi_daily_data_5_years.csv (tail) ---" | |
| tail -n 5 data/karachi_daily_data_5_years.csv | |
| # Step 5: Commit the newly updated CSV files back to your repository | |
| - name: Commit and push changes | |
| run: | | |
| git config --global user.name "GitHub Actions Bot" | |
| git config --global user.email "actions-bot@github.com" | |
| git add data/last_7_days_hourly_data.csv | |
| git add data/last_7_days_daily_data.csv | |
| git add data/karachi_daily_data_5_years.csv | |
| git status | |
| git commit -m "Automated data update and aggregation" | |
| git push |