Blog: feature ucacher (#867) #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/suggested_posts.py --popular > blog/_data/related_popular_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 |