-
Notifications
You must be signed in to change notification settings - Fork 43
69 lines (59 loc) · 1.82 KB
/
data-refresh.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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