Update Data and Deploy #211
This file contains hidden or 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==2.31.0 datasette==0.65.1 geojson-to-sqlite==0.1.1 datasette-geojson==0.3 | |
- 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 dev-locations/locations.db .python-version | |
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: | | |
# Install Heroku CLI | |
curl https://cli-assets.heroku.com/install.sh | sh | |
# Install required Heroku plugin (non-interactive) | |
heroku plugins:install heroku-builds --force | |
# Deploy to Heroku | |
datasette publish heroku dev-locations/locations.db \ | |
--metadata dev-locations/metadata.json \ | |
--static static:dev-locations/static \ | |
-n tampa-dev-coord-db |