Skip to content

Update Map Every 12 Hours #3

Update Map Every 12 Hours

Update Map Every 12 Hours #3

Workflow file for this run

# .github/workflows/update_map.yml
name: Update Map Every 12 Hours
on:
workflow_dispatch: # Allow manual trigger
schedule:
# Cron syntax, '0 */12 * * *' means run every 12 hours (at 00:00 and 12:00 UTC)
- cron: '0 */12 * * *'
jobs:
build-and-commit:
runs-on: ubuntu-latest
permissions:
contents: write # Grant write permissions
steps:
# Step 1: Check out your repository code
- name: Check out repo
uses: actions/checkout@v4
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
# Step 3: Install Python dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install matplotlib pandas geopandas
# Step 4: Run your Python script to generate the map
- name: Generate map
run: python generate_map.py
# Step 5: Update README with a cache-busting query
- name: Update README
run: |
# Use sed to find the markdown image link and append a timestamp
timestamp=$(date +%s)
sed -i "s|(!\[My Real-time Map\](map.png))[?a-zA-Z0-9=]*|\1?timestamp=${timestamp}|g" README.md
# Step 6: Commit the updated map and README file
- name: Commit and push if it changed
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'CI: Auto-update map and README'
file_pattern: 'map.png README.md'
commit_user_name: 'GitHub Actions Bot'
commit_user_email: 'actions@github.com'
commit_author: 'GitHub Actions Bot <actions@github.com>'