Skip to content

Commit 150202c

Browse files
authored
Merge pull request #14 from lockdown-systems/update
add gh action to automate updates
2 parents 2e0c2bb + 3f9ef54 commit 150202c

5 files changed

Lines changed: 6513 additions & 1 deletion

File tree

.github/workflows/update-data.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Update ICEWatch Data
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 12 * * *' # every day at noon UTC
7+
8+
jobs:
9+
update-data:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repo
13+
uses: actions/checkout@v3
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.11'
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install -r requirements.txt
24+
25+
- name: Download latest XLS
26+
id: download
27+
run: |
28+
python ice_detention_scraper.py
29+
XLS=$(ls -t data/*.xlsx | head -n1)
30+
# Check if the XLS file is new or changed
31+
if [ -z "$(git status --porcelain $XLS)" ]; then
32+
echo "No new XLS file. Exiting workflow."
33+
exit 0
34+
fi
35+
echo "xls_file=$XLS" >> $GITHUB_OUTPUT
36+
37+
- name: Parse XLS to JSON
38+
id: parse
39+
run: |
40+
python ice_detention_scraper.py --extract-from-file "${{ steps.download.outputs.xls_file }}"
41+
JSON=$(ls -t data/ice_facilities_*.json | head -n1)
42+
echo "json_file=$JSON" >> $GITHUB_OUTPUT
43+
44+
- name: Geocode facilities
45+
id: geocode
46+
run: |
47+
GEOJSON="data/facilities_geocoded_$(date +%Y%m%d).json"
48+
python geocode_facilities.py --input "${{ steps.parse.outputs.json_file }}" --output "$GEOJSON" --cache data/geocode_cache.json
49+
if grep -q '\"latitude\": null' "$GEOJSON"; then
50+
echo "::warning ::Some facilities could not be geocoded. Please update geocode_cache.json."
51+
fi
52+
echo "geojson_file=$GEOJSON" >> $GITHUB_OUTPUT
53+
54+
- name: Render site
55+
run: |
56+
python render_facilities_map.py --input "${{ steps.geocode.outputs.geojson_file }}"
57+
58+
- name: Commit and push changes
59+
uses: stefanzweifel/git-auto-commit-action@v5
60+
with:
61+
commit_message: "Automated update: refresh ICEWatch data and site"
62+
file_pattern: docs/index.html data/*.json data/*.xlsx data/geocode_cache.json
1.49 MB
Binary file not shown.

0 commit comments

Comments
 (0)