Fetch latest outages #36878
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
name: Fetch latest outages | |
on: | |
push: | |
workflow_dispatch: | |
schedule: | |
- cron: '*/10 * * * *' | |
permissions: | |
contents: write | |
jobs: | |
fetch: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
cache: 'pip' | |
- name: Install Python tools | |
run: pip install -r requirements.txt | |
- name: Fetch | |
run: | | |
curl -s "https://ags.pge.esriemcs.com/arcgis/rest/services/43/outages/MapServer/5/query?where=1%3D1&outFields=*&f=pjson&_$(uuidgen)" \ | |
| jq '.features | map({ | |
attributes: (.attributes | del(.blueSkyNotificationSubscription, .OBJECTID)), | |
geometry_x: .geometry.x, | |
geometry_y: .geometry.y | |
} | .attributes + {geometry_x: .geometry_x, geometry_y: .geometry_y})' \ | |
> outages-new.json | |
head -n 20 outages-new.json | |
head -n 20 outages.json | |
- name: Generate commit message, commit and push | |
run: |- | |
csv-diff outages.json outages-new.json --key F_OUTAGE_ID --format json > message.txt | |
mv outages-new.json outages.json | |
git config user.name "Automated" | |
git config user.email "actions@users.noreply.github.com" | |
git add outages.json | |
git commit -F message.txt || exit 0 | |
git pull --rebase | |
git push |