Skip to content

Update ICEWatch Data #313

Update ICEWatch Data

Update ICEWatch Data #313

Workflow file for this run

name: Update ICEWatch Data
on:
workflow_dispatch:
schedule:
- cron: "0 12 * * *" # every day at noon UTC
jobs:
update-data:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- 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 .
- name: Download latest XLS
id: download
run: |
icewatch scrape
XLS=$(ls -t data/*.xlsx | head -n1)
# Check if the XLS file is new or changed
if [ -z "$(git status --porcelain $XLS)" ]; then
echo "No new XLS file. Exiting workflow."
echo "new_file=false" >> $GITHUB_OUTPUT
else
echo "xls_file=$XLS" >> $GITHUB_OUTPUT
echo "new_file=true" >> $GITHUB_OUTPUT
fi
- name: Parse XLS to JSON
id: parse
if: steps.download.new_file == 'true'
run: |
icewatch scrape --extract-from-file "${{ steps.download.outputs.xls_file }}"
JSON=$(ls -t data/ice_facilities_*.json | head -n1)
echo "json_file=$JSON" >> $GITHUB_OUTPUT
- name: Geocode facilities
id: geocode
if: steps.download.new_file == 'true'
run: |
GEOJSON="data/facilities_geocoded_$(date +%Y%m%d).json"
icewatch geocode --input "${{ steps.parse.outputs.json_file }}" --output "$GEOJSON" --cache data/geocode_cache.json
if grep -q '\"latitude\": null' "$GEOJSON"; then
echo "::warning ::Some facilities could not be geocoded. Please update geocode_cache.json."
fi
- name: Render site
run: |
icewatch render --latest --update-last-checked
- name: Add all changes
run: |
git add -A
git status
echo "Files to be committed:"
git diff --cached --name-only
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.ICEWATCH_PAT }}
commit-message: "Automated update: refresh ICEWatch data and site"
title: "Automated update: refresh ICEWatch data and site"
body: |
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: automated-update
branch-suffix: timestamp
delete-branch: true
- name: Enable PR Automerge
run: gh pr merge --merge --auto "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.ICEWATCH_PAT }}