Skip to content

Fetch Data and Create Image #20924

Fetch Data and Create Image

Fetch Data and Create Image #20924

Workflow file for this run

name: Fetch Data and Create Image
on:
schedule:
- cron: '*/1200 * * * *' # Run this action every 5 minutes
workflow_dispatch:
jobs:
fetch-and-create:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
lfs: true
- name: Checkout LFS objects
run: git lfs checkout
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install requests pandas Pillow
- name: Fetch data
run: python fetch.py
- name: Create Image if new data
run: |
NEW_DATA=$(tail -1 sismos_ipma.csv | cut -d, -f1)
if [[ "$NEW_DATA" != "$(cat latest_data.txt)" ]]; then
python create_image.py
echo "$NEW_DATA" > latest_data.txt
fi
- name: Commit and push if there's new data
run: |
git config --global user.email "hello@vost.pt"
git config --global user.name "vospt"
git add sismos_ipma.csv latest_data.txt
git commit -m "Update data" || echo "No changes to commit"
git push origin