Update Data and Deploy #78
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 'action@github.com' | |
git add dev-locations/locations.db | |
git diff --quiet && git diff --staged --quiet || (git commit -m "Update locations $(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 | |
datasette publish heroku dev-locations/locations.db \ | |
--metadata dev-locations/metadata.json \ | |
--static static:dev-locations/static \ | |
-n tampa-dev-coord-db |