automatic-data-update #4
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: python leetcomp/refresh.py | |
- name: Parsing Data... | |
run: 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 commit -m "action: daily data refresh" | |
git push | |
- name: Create Pull Request | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const { repo, owner } = context.repo; | |
const result = await github.rest.pulls.create({ | |
title: 'Automatic Data Update', | |
owner, | |
repo, | |
head: '${{ github.ref_name }}', | |
base: 'main', | |
body: [ | |
'Automatic LeetCode data update', | |
] | |
}); |