Update Energy Price Data #19
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: Update Energy Price Data | |
| permissions: | |
| contents: write | |
| on: | |
| schedule: | |
| # Run every hour at minute 5 | |
| - cron: '5 * * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| update-data: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: true | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -r requirements.txt | |
| - name: Download latest data | |
| env: | |
| ENTSOE_API_KEY: ${{ secrets.ENTSOE_API_KEY }} | |
| run: | | |
| python src/main.py download | |
| - name: Commit and push if changed | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| shell: bash | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add data/ | |
| git diff --quiet && git diff --staged --quiet || (git commit -m "Update energy price data - $(date -u +'%Y-%m-%d %H:%M UTC')" && git push) |