-
Notifications
You must be signed in to change notification settings - Fork 8
66 lines (63 loc) · 2.17 KB
/
suggestion-generate.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
name: Generate Suggestions ( Related Posts )
on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'blog/_posts/*.md'
jobs:
build-website:
name: Build Suggestions
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, '[AUTO-PR]') == false"
steps:
- name: Check Required Secrets
run: |
if [ -z "${{ secrets.OPENAI_API_KEY }}" ]; then
echo "Error: OPENAI_API_KEY is not set."
exit 1
fi
if [ -z "${{ secrets.ANTHROPIC_API_KEY }}" ]; then
echo "Error: ANTHROPIC_API_KEY is not set."
exit 1
fi
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- uses: FranzDiebold/github-env-vars-action@v2
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11' # This will get the latest version of Python 3
- name: Create a new branch
run: |
git config user.name 'GitHub Actions Bot'
git config user.email '[email protected]'
- name: Dependencies
run: |
set -x
curl -sSL https://install.python-poetry.org | python3 -
poetry install --no-root
- name: Run Code
run: |
set -x
poetry run python ./util/psupport/psupport/scripts/suggested_posts.py > blog/_data/related_articles.yml
poetry run python ./util/psupport/psupport/scripts/short_titles.py > blog/_data/short_titles.yml
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- name: Check for changes
id: changes
run: |
git diff --exit-code || echo "::set-output name=has_changes::true"
- name: Commit changes
if: steps.changes.outputs.has_changes == 'true'
run: |
git add -A
git commit -m "[AUTO-PR] related_articles.yml update"
git push