Sync Member Publications #20
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
name: Sync Member Publications | |
on: | |
# Run daily at 6 AM UTC | |
schedule: | |
- cron: '0 6 * * *' | |
# Allow manual triggering | |
workflow_dispatch: | |
# Run on pushes to main branch if members.yml is changed | |
push: | |
branches: [main] | |
paths: | |
- 'members.yml' | |
# Prevent concurrent deployments to avoid conflicts | |
concurrency: | |
group: "sync-posts" | |
cancel-in-progress: false | |
jobs: | |
sync-posts: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # Allow pushing changes back to the repository | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pyyaml requests | |
- name: Run member publication synchronization | |
run: | | |
python sync_member_posts.py --verbose | |
env: | |
# Provide GitHub token for potential API usage in the future | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check for changes | |
id: check_changes | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
echo "changes=true" >> $GITHUB_OUTPUT | |
else | |
echo "changes=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit and push changes | |
if: steps.check_changes.outputs.changes == 'true' | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add publications/ | |
git commit -m "Sync member publications - $(date -u +%Y%m%d-%H%M%S)" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create summary | |
run: | | |
echo "## Member Publication Sync Summary" >> $GITHUB_STEP_SUMMARY | |
echo "Synchronization completed at $(date -u)" >> $GITHUB_STEP_SUMMARY | |
if [ "${{ steps.check_changes.outputs.changes }}" == "true" ]; then | |
echo "✅ Changes detected and committed to repository" >> $GITHUB_STEP_SUMMARY | |
else | |
echo "ℹ️ No new publications found" >> $GITHUB_STEP_SUMMARY | |
fi | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "### Current member publications:" >> $GITHUB_STEP_SUMMARY | |
if [ -d "publications" ]; then | |
find publications -type d -name "*-*" | grep -v "_template" | sort | while read -r dir; do | |
echo "- $dir" >> $GITHUB_STEP_SUMMARY | |
done | |
fi |