Skip to content

automatic-data-update #55

automatic-data-update

automatic-data-update #55

Workflow file for this run

name: automatic-data-update
on:
schedule:
- cron: '00 22 * * 3,6'
jobs:
automatic-data-update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Create and start virtual environment
run: |
python3 -m venv .venv
source .venv/bin/activate
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Data Refresh...
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
run: |
export PYTHONPATH=.
python leetcomp/refresh.py
- name: Parsing Data...
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
run: |
export PYTHONPATH=.
python leetcomp/parse.py
- name: Commit files
id: commit-files
run: |
git config --global user.name github-actions
git config --global user.email github-actions@github.com
git add .
git diff --staged --exit-code || has_changes=$?
if [ "$has_changes" == "1" ]; then
echo "Changes detected, committing..."
git commit -m "action: daily data refresh"
else
echo "No changes to commit."
echo "skipnext=true" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: (steps.commit-files.outputs.skipnext != 'true')
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GH_TOKEN }}
commit-message: Update content
title: "Automated PR to refresh data"
body: "This is an automated pull request to refresh the data."
branch: "data-refresh"
delete-branch: true
draft: false