Update Data and Deploy #18
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
# .github/workflows/update-data.yml | |
name: Update Data and Deploy | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Run daily at midnight UTC | |
workflow_dispatch: # Allow manual triggers | |
push: | |
branches: | |
- main | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests datasette geojson-to-sqlite | |
- name: Run update script | |
run: python script.py | |
- name: Commit and push if changed | |
run: | | |
git config --global user.name 'GitHub Action' | |
git config --global user.email '[email protected]' | |
git add data.db | |
git diff --quiet && git diff --staged --quiet || (git commit -m "Update data $(date -u)" && git push) | |
- name: Deploy to Heroku | |
env: | |
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} | |
run: | | |
curl https://cli-assets.heroku.com/install.sh | sh | |
heroku plugins:install datasette-publish-heroku | |
datasette publish heroku data.db -n tampa-dev-coord-db |