NHL API pull data for game-level stats (games and odds) #134
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: NHL API pull data for game-level stats (games and odds) | |
on: | |
schedule: | |
- cron: '0 20 * * *' # This runs the workflow daily at 20:00 UTC, which is 3 PM CT during Daylight Saving Time | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
update-and-commit: | |
runs-on: ubuntu-latest | |
environment: data-collection | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Conda - Set up Miniconda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: '3.12.2' # Specify the Python version you need | |
channels: conda-forge,defaults # Add conda-forge and defaults channels | |
- name: Conda - Initialize Conda | |
run: | | |
conda init bash | |
source ~/.bashrc | |
- name: Conda - Create environment and install Conda dependencies | |
run: | | |
conda create --name myenv --yes | |
source ~/.bashrc | |
conda activate myenv | |
conda install --yes --file src/requirements/conda_requirements.txt | |
- name: Conda - Install Pip dependencies | |
run: | | |
source ~/.bashrc | |
conda activate myenv | |
pip install -r src/requirements/pip_requirements.txt | |
- name: Run Python - NHL Game Record Data | |
run: | | |
source ~/.bashrc | |
conda activate myenv | |
python src/data/apinhle/data_pull_box.py | |
- name: Run Python - NHL Odds Data | |
run: | | |
source ~/.bashrc | |
conda activate myenv | |
python src/data/apinhle/data_pull_box_odds.py | |
- name: Run Python - NHL Game-level Summary to Game Records and Season-team Statistics | |
if: always() | |
run: | | |
source ~/.bashrc | |
conda activate myenv | |
python src/data/apinhle/data_proc_gameSummary.py | |
- name: Run Python - NHL Game-level Play-by-play record data | |
if: always() | |
run: | | |
source ~/.bashrc | |
conda activate myenv | |
python src/data/apinhle/data_pull_plays.py | |
- name: Configure Git | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Commit and push changes | |
run: | | |
git add latest/box/*.csv | |
git add latest/team/season/*.csv | |
if git diff-index --quiet HEAD --; then | |
echo "No changes to commit" | |
exit 0 | |
else | |
git commit -m 'Automated data update' | |
git push | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |