Update Citations Page #1
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: 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 "==========================================" |