-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (68 loc) · 2.65 KB
/
auto-upload-contents.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
70
71
72
73
74
75
76
name: Auto Upload Contents
on:
workflow_dispatch:
inputs:
n_content:
description: "Number of posts to generate and upload"
required: true
default: "1"
topic:
description: "Topic for content generation"
required: true
default: "Free Topic"
enable_langchain_tracing:
description: "Enable LangChain tracing (true/false)"
required: false
default: "false"
schedule:
- cron: "0 0 * * 1" # Run every Monday at 00:00 UTC
jobs:
generate-content:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'schedule' && vars.ENABLE_SCHEDULED_POSTING == 'true') }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Generate content
run: |
source $VENV
export PYTHONPATH=$PYTHONPATH:${{ github.workspace }}
if [ "${{ github.event_name }}" = "schedule" ]; then
python scripts/generate_content.py \
--n-content ${{ vars.SCHEDULED_POST_COUNT || 5 }} \
--topic "${{ vars.SCHEDULED_POST_TOPIC || 'Free Topic' }}"
else
python scripts/generate_content.py \
--n-content ${{ github.event.inputs.n_content }} \
--topic "${{ github.event.inputs.topic }}"
fi
env:
VENV: ${{ github.workspace }}/.venv/bin/activate
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
LANGCHAIN_TRACING_V2: ${{ github.event.inputs.enable_langchain_tracing }}
LANGCHAIN_API_KEY: ${{ secrets.LANGCHAIN_API_KEY }}
- name: Commit and push if changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
git diff --quiet && git diff --staged --quiet || (git commit -m "📝 Add generated content for ${{ github.event.inputs.topic || vars.SCHEDULED_POST_TOPIC || 'Free Topic' }}" --no-verify && git push)