Skip to content

Update data

Update data #1331

Workflow file for this run

name: Update data
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
GEOCODIO_API_KEY: ${{secrets.GEOCODIO_API_KEY}}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
lfs: 'true'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgeos-dev libudunits2-dev libgdal-dev libcurl4-openssl-dev webp libharfbuzz-dev libfribidi-dev
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Cache Python
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('gen/scripts/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install and run Python
run: |
pip install -r gen/scripts/requirements.txt
python gen/scripts/nlrb.py
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: 4.3.2
- name: Cache packages
uses: actions/cache@v4
with:
path: ~/.local/share/renv
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
- name: Restore packages
shell: Rscript {0}
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
renv::restore()
- name: Get New Data
run: Rscript gen/scripts/Update_Data.R
- name: Prep New Data
run: Rscript gen/scripts/Init.R
- name: Commit new data
id: commit
uses: EndBug/add-and-commit@v9 # You can change this to use a specific version
with:
add: "['gen/data/recent_election_results.csv', 'gen/data/open_petitions.csv']"
message: 'Updated data'
- name: Setup Quarto
uses: quarto-dev/quarto-actions/setup@v2
- name: Build and Publish to Netlify
uses: South-Paw/action-netlify-cli@v2
with:
args: 'deploy --prod --build'
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Finish and comit
id: commitfinal
uses: EndBug/add-and-commit@v9 # You can change this to use a specific version
with:
message: 'Updated plots'