Skip to content

Sync Member Publications #159

Sync Member Publications

Sync Member Publications #159

name: Sync Member Publications
on:
# Run daily at 6 AM UTC
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
# Run when members.yml is modified
push:
branches: [main]
paths:
- 'members.yml'
- 'sync_member_posts.py'
# Prevent concurrent executions
concurrency:
group: "sync-posts"
cancel-in-progress: false
jobs:
sync-posts:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
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@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
# Install dependencies for sync script (separate from Quarto rendering)
pip install pyyaml requests
- name: Run member publication synchronization
run: python sync_member_posts.py --verbose
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for changes
id: check_changes
run: |
if [ -n "$(git status --porcelain publications/)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changes == 'true'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add publications/
git commit -m "chore: sync member publications [skip ci]" \
-m "Automated synchronization at $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
git push
- name: Create summary
if: always()
run: |
echo "## 📚 Member Publication Sync Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Completed at:** $(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.check_changes.outputs.changes }}" == "true" ]; then
echo "### ✅ Changes Detected" >> $GITHUB_STEP_SUMMARY
echo "New publications have been synchronized and committed to the repository." >> $GITHUB_STEP_SUMMARY
else
echo "### ℹ️ No Changes" >> $GITHUB_STEP_SUMMARY
echo "No new publications found. All publications are up to date." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📁 Current Publications" >> $GITHUB_STEP_SUMMARY
if [ -d "publications" ]; then
pub_count=$(find publications -type d -name "*-*" | grep -v "_template" | wc -l)
echo "Total member publication directories: **${pub_count}**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "<details><summary>View all publication directories</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
find publications -type d -name "*-*" | grep -v "_template" | sort | while read -r dir; do
echo "- \`$dir\`" >> $GITHUB_STEP_SUMMARY
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
fi