-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (38 loc) · 1.53 KB
/
update-quote.yml
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
name: GitHub Self-Updating Stoic Quote
on:
schedule:
- cron: "0 0 * * *" # Runs daily at midnight
workflow_dispatch: # Allows manual triggering
permissions:
contents: write # Grant write permissions
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
jobs:
update-quote:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11" # or your preferred Python version
- name: Install dependencies
run: |
pip install --upgrade pip
pip install kathekon
- name: Run script to update README and files
run: kathekon readme daily
- name: Insert current date into README
run: |
python3 -c "import datetime, re; filename = 'README.md'; text = open(filename).read(); updated = re.sub(r'<!--date-start-->.*?<!--date-end-->', '<!--date-start-->{}<!--date-end-->'.format(datetime.datetime.now().strftime('%A, %B %d, %Y')), text, flags=re.DOTALL); open(filename, 'w').write(updated)"
- name: Configure Git
run: |
git config --global user.name "janthmueller"
git config --global user.email "janthmueller@users.noreply.github.com"
- name: Commit and Push changes
run: |
now=$(date)
git add .
git commit -m "Auto-update Stoic Quote on $now" || echo "No changes to commit"
git push