Generate Blog #73
This file contains hidden or 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
| # https://chat.deepseek.com/a/chat/s/a55bd8ef-a8b5-44ee-8364-cd2a15fb270d | |
| name: Generate Blog | |
| on: | |
| workflow_dispatch: # Allows manual triggering | |
| schedule: | |
| - cron: "0 0 * * 1" # Runs every Monday at midnight (optional) | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| generate-blog: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.9" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install requests openai python-dotenv pydantic | |
| - name: Run Python script | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| run: python scripts/generate_blog.py | |
| # TODO: Get the title for the PR title | |
| # - name: Extract blog title | |
| # id: extract_title | |
| # run: | | |
| # BLOG_TITLE=$(grep -m 1 '^title:' content/blogs/*.mdx | sed -E 's/^title: ["'\'']?([^"'\'']+)["'\'']?/\1/' | head -n 1) | |
| # echo "Extracted title: $BLOG_TITLE" | |
| # echo "BLOG_TITLE=${BLOG_TITLE}" >> $GITHUB_ENV | |
| - name: Set unique branch name | |
| id: set_branch | |
| run: echo "BRANCH_NAME=new-blog-post-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| commit-message: "Add new blog post - TODO: Get title" | |
| title: "New blog post - TODO: Get title" | |
| body: "This PR adds a new blog post generated by the GitHub Action using OpenAI API" | |
| branch: "${{ env.BRANCH_NAME }}" |