-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (57 loc) · 1.85 KB
/
run-python.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Python Script Runner
on:
push:
branches:
- "**"
paths:
- "diffs/**/*"
permissions:
contents: write
jobs:
run-python-script:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
save-always: true
key: "${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run script
run: python main.py
env:
CURRENT_REPO_URL: "${{ github.server_url }}/${{ github.repository }}/blob/"
OPEN_AI_API_KEY: ${{ secrets.OPEN_AI_API_KEY }}
TELEGRAM_CHAT_ID: ${{ vars.TELEGRAM_CHAT_ID }}
OPENAI_MODEL: ${{ secrets.OPENAI_MODEL }}
- name: Commit and push changes
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Created Post"
git push
- name: Notify Slack
if: env.WEBHOOK_URL
run: |
curl -X POST -H 'Content-type: application/json' -d @slack.json ${{ secrets.SLACK_WEBHOOK_URL }}
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Notify Telegram
if: env.BOT_TOKEN
run: |
curl -X POST -H 'Content-type: application/json' -d @telegram.json https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage
env:
BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}