Update Model #19
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 Model | |
on: | |
schedule: | |
- cron: "0 0 * * *" # Run every day at 00:00 UTC | |
workflow_dispatch: | |
jobs: | |
run-script: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run the script | |
run: python code/data_fetcher.py --all | |
- name: Commit and push if there are changes | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "" | |
git add . | |
git diff-index --quiet HEAD || git commit -m "Update model" | |
git push https://${{ secrets.ELECTIONMODELKEY }}@github.com/BPR-Data-Team/ElectionModel2024.git | |
run-r-script: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: '4.1.2' | |
- name: Install R dependencies | |
run: | | |
install.packages(c("tidyverse", "glue", "tidycensus", "lubridate")) | |
- name: Run the R script | |
env: | |
CENSUS_API_KEY: ${{ secrets.CENSUS_API }} | |
run: | | |
Rscript code/ContinuousCleaning/CensusDemographics.R | |
Rscript code/ContinuousCleaning/Fundamentals.R | |
- name: Commit and push if there are changes | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "" | |
git add . | |
git diff-index --quiet HEAD || git commit -m "Update model" | |
git push https://${{ secrets.ELECTIONMODELKEY }}@github.com/BPR-Data-Team/ElectionModel2024.git | |