Skip to content

Update Citations Page #1

Update Citations Page

Update Citations Page #1

name: Update Citations Page
on:
schedule: # execute every week on Monday at midnight
- cron: "0 0 * * 1"
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
jobs:
update-citations:
name: πŸ“š Update Citations Page
runs-on: ubuntu-latest
steps:
- name: πŸ“₯ Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: 🐍 Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: πŸ“¦ Install Python dependencies
run: |
echo "πŸ“¦ Installing Python dependencies..."
pip install -r scripts/citations/requirements.txt
echo "βœ… Dependencies installed"
- name: πŸ” Verify dependencies
run: |
echo "πŸ” Verifying installed packages..."
python3 -c "import requests; print(f'βœ“ requests {requests.__version__}')"
python3 -c "import bs4; print(f'βœ“ beautifulsoup4 installed')"
python3 -c "import lxml; print(f'βœ“ lxml installed')"
echo "βœ… All dependencies verified"
- name: πŸ“š Generate citations page
run: |
echo "πŸ“š Generating citations page..."
echo "πŸ“Š Retrieving citations from Google Scholar..."
cd scripts/citations
python3 generate_citations_page.py
echo "βœ… Citations page generated"
- name: πŸ“Š Check if file was generated
run: |
if [ -f "about/citations.md" ]; then
echo "βœ… Citations page exists"
echo "πŸ“„ File size: $(stat -f%z about/citations.md 2>/dev/null || stat -c%s about/citations.md 2>/dev/null) bytes"
echo ""
echo "πŸ“‹ First 10 lines:"
head -n 10 about/citations.md
else
echo "❌ Citations page not found!"
exit 1
fi
- name: πŸ”§ Configure git
run: |
echo "πŸ”§ Configuring git user..."
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
echo "βœ… Git user configured"
- name: πŸ“ Commit and push changes
run: |
echo "🌳 Checking git status..."
git status
echo ""
echo "πŸ“š Adding citations page..."
git add about/citations.md
# Check if there are changes to commit
if git diff --cached --quiet; then
echo "ℹ️ No changes detected in citations page"
echo "πŸ“š Page is already up to date"
exit 0
fi
echo "βœ… Changes detected, preparing commit..."
echo ""
echo "πŸ“‹ Files to be committed:"
git diff --cached --name-status
echo ""
echo "πŸ“ Committing changes..."
TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M UTC")
git commit -m "πŸ“š Update citations page" \
-m "Automated update of the citations page from Google Scholar" \
-m "Generated on: $TIMESTAMP" \
-m "" \
-m "This commit was automatically created by the Update Citations workflow."
echo "βœ… Changes committed"
echo ""
echo "πŸš€ Pushing to repository..."
git push origin main || git push origin master
echo "βœ… Changes pushed successfully"
- name: βœ… Workflow summary
if: always()
run: |
echo ""
echo "=========================================="
echo "πŸ“š Citations Page Update Summary"
echo "=========================================="
echo ""
if [ -f "about/citations.md" ]; then
echo "βœ… Citations page: Generated"
echo "πŸ“ Location: about/citations.md"
echo "🌐 URL: https://control-toolbox.org/citations/"
else
echo "❌ Citations page: Failed to generate"
fi
echo ""
echo "πŸ•’ Workflow completed at: $(date -u +"%Y-%m-%d %H:%M UTC")"
echo "=========================================="