automatic-data-update #8
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: automatic-data-update | |
on: | |
schedule: | |
# Runs at 1 PM UTC, which is 6:30 PM IST | |
- cron: '*/15 * * * *' | |
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... | |
run: | | |
export PYTHONPATH=. | |
python leetcomp/refresh.py | |
- name: Parsing Data... | |
run: | | |
export PYTHONPATH=. | |
python leetcomp/parse.py | |
- name: 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" | |
git push | |
else | |
echo "No changes to commit." | |
exit 1 | |
fi | |
- name: Create Pull Request | |
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 |