Update open house data #8612
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: Update open house data | |
concurrency: scrape | |
on: | |
schedule: | |
- cron: '0 */5 * * *' | |
workflow_dispatch: | |
jobs: | |
scrape-and-commit: | |
runs-on: ubuntu-latest | |
environment: scrape | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
- name: Scrape and commit | |
env: | |
OH_SESSION_COOKIE: ${{ secrets.OH_SESSION_COOKIE }} | |
run: | | |
sudo apt-get install libgeos-dev | |
pip install -r requirements.txt | |
# we'll regenerate these, so remove them now and git add -u will | |
# later mark them as deleted in git | |
rm data/2023/* || true | |
rm csv/2023/* || true | |
rm -rf maps/2023/* || true | |
python -u scrape-openhouse.py | |
python -u generate-csv-summary.py | |
python -u generate-maps.py | |
mv data data.new | |
mv csv csv.new | |
mv maps maps.new | |
git checkout -- data | |
git checkout -- csv | |
git checkout -- maps | |
git pull --ff-only | |
rm -rf data | |
rm -rf csv | |
rm -rf maps | |
mv data.new data | |
mv csv.new csv | |
mv maps.new maps | |
# -u because we want to also remove any files that have been deleted | |
git add data | |
git add csv | |
git add maps | |
git config --global user.email "bot@jonty.co.uk" | |
git config --global user.name "OH London update GHA" | |
# || true means this won't error when there's nothing to commit | |
git commit -m "Automatic OH London data update" || true | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} |