Sync Posts #57
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: Sync Posts | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
jobs: | |
sync-posts: | |
runs-on: ubuntu-latest | |
environment: Website | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Cache Python dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('code/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --no-cache-dir -r code/requirements.txt | |
- name: Export WordPress posts | |
env: | |
API_URL: ${{ secrets.API_URL }} | |
USERNAME: ${{ secrets.USERNAME }} | |
APP_PASSWORD: ${{ secrets.APP_PASSWORD }} | |
run: | | |
python code/export_posts.py | |
- name: Commit and push changes | |
run: | | |
git config --global user.name "${{ secrets.GIT_USER_NAME }}" | |
git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" | |
git add . | |
git commit -m "Update WordPress posts on $(date)" || echo "No changes to commit" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
branch: sync-wordpress-posts | |
commit-message: "Sync WordPress posts" | |
title: "Daily WordPress Post Sync" | |
body: "This PR syncs posts from WordPress to this repo." |