Update GeoJSON File #4
This file contains 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 GeoJSON File | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs once every day at midnight (UTC) | |
workflow_dispatch: # Allows you to trigger the action manually | |
jobs: | |
fetch-and-update-geojson: | |
runs-on: ubuntu-latest | |
steps: | |
# Check out your repository code | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Ensure full history is fetched | |
# Download the GeoJSON file from Google Drive | |
- name: Download GeoJSON file | |
run: | | |
curl -L -o data/aba_alert.json "https://drive.google.com/uc?export=download&id=${{secrets.GDRIVE_FILE_ID_ABA_ALERT}}" | |
curl -L -o data/life_needs_alert.json "https://drive.google.com/uc?export=download&id=${{secrets.GDRIVE_FILE_ID_LIFE_NEEDS_ALERT}}" | |
curl -L -o data/year_needs_alert.json "https://drive.google.com/uc?export=download&id=${{secrets.GDRIVE_FILE_ID_YEAR_NEEDS_ALERT}}" | |
# Commit and push changes | |
- name: Commit and push changes | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "actions@github.com" | |
# Pull the latest changes with rebase | |
git pull --rebase origin main || echo "No changes to rebase" | |
# Add and commit changes | |
git add data/aba_alert.json data/life_needs_alert.json data/year_needs_alert.json | |
git commit -m "Update GeoJSON file" || echo "No changes to commit" | |
# Push changes, retry with force if needed | |
git push || (git pull --rebase origin main && git push --force) |