|
| 1 | +name: Update Google Scholar Citations |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 0 * * 1" # Monday |
| 6 | + - cron: "0 0 * * 3" # Wednesday |
| 7 | + - cron: "0 0 * * 5" # Friday |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + update-citations: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + # See CUSTOMIZE.md for details on how to set up PAT for triggering subsequent workflows |
| 18 | + # with: |
| 19 | + # token: ${{ secrets.PAT }} |
| 20 | + |
| 21 | + - name: Set up Python |
| 22 | + uses: actions/setup-python@v4 |
| 23 | + with: |
| 24 | + python-version: "3.13" |
| 25 | + |
| 26 | + - name: Install dependencies |
| 27 | + run: | |
| 28 | + echo "🔧 Installing dependencies..." |
| 29 | + python -m pip install --upgrade pip |
| 30 | + pip install -r requirements.txt |
| 31 | +
|
| 32 | + - name: Save current citations.yml hash |
| 33 | + id: before |
| 34 | + run: | |
| 35 | + echo "📦 Checking existing citations.yml hash..." |
| 36 | + if [ -f _data/citations.yml ]; then |
| 37 | + sha_before=$(sha256sum _data/citations.yml | awk '{print $1}') |
| 38 | + echo "sha_before=$sha_before" >> $GITHUB_OUTPUT |
| 39 | + echo "📝 SHA before: $sha_before" |
| 40 | + else |
| 41 | + echo "sha_before=none" >> $GITHUB_OUTPUT |
| 42 | + echo "📝 No existing citations.yml file found." |
| 43 | + fi |
| 44 | +
|
| 45 | + - name: Run citation update script |
| 46 | + id: run_citation_update |
| 47 | + shell: bash |
| 48 | + run: | |
| 49 | + set +e |
| 50 | + echo "🚀 Running citation update script (single attempt)..." |
| 51 | + start_time=$(date) |
| 52 | + timeout 90 python bin/update_scholar_citations.py |
| 53 | + status=$? |
| 54 | + end_time=$(date) |
| 55 | + if [ $status -eq 0 ]; then |
| 56 | + echo "✅ Citation update succeeded (started at $start_time, ended at $end_time)." |
| 57 | + echo "✅ Citation update succeeded." >> $GITHUB_STEP_SUMMARY |
| 58 | + else |
| 59 | + echo "❌ Citation update script failed with exit code $status (started at $start_time, ended at $end_time)." |
| 60 | + echo "❌ Citation update script failed with exit code $status." >> $GITHUB_STEP_SUMMARY |
| 61 | + fi |
| 62 | + set -e |
| 63 | +
|
| 64 | + - name: Save new citations.yml hash |
| 65 | + id: after |
| 66 | + run: | |
| 67 | + echo "🔍 Checking updated citations.yml hash..." |
| 68 | + if [ -f _data/citations.yml ]; then |
| 69 | + sha_after=$(sha256sum _data/citations.yml | awk '{print $1}') |
| 70 | + echo "sha_after=$sha_after" >> $GITHUB_OUTPUT |
| 71 | + echo "📝 SHA after: $sha_after" |
| 72 | + else |
| 73 | + echo "sha_after=none" >> $GITHUB_OUTPUT |
| 74 | + echo "📝 citations.yml was not created or is missing." |
| 75 | + fi |
| 76 | +
|
| 77 | + - name: Report citations.yml change in summary |
| 78 | + run: | |
| 79 | + echo "📋 Comparing citation file hashes..." |
| 80 | + if [ "${{ steps.before.outputs.sha_before }}" != "${{ steps.after.outputs.sha_after }}" ]; then |
| 81 | + echo "✅ _data/citations.yml was updated." |
| 82 | + echo "✅ _data/citations.yml was updated." >> $GITHUB_STEP_SUMMARY |
| 83 | + else |
| 84 | + echo "ℹ️ _data/citations.yml was not changed." |
| 85 | + echo "ℹ️ _data/citations.yml was not changed." >> $GITHUB_STEP_SUMMARY |
| 86 | + fi |
| 87 | +
|
| 88 | + - name: Configure Git |
| 89 | + run: | |
| 90 | + git config --local user.email "[email protected]" |
| 91 | + git config --local user.name "GitHub Actions" |
| 92 | + echo "🔧 Git configured." |
| 93 | +
|
| 94 | + - name: Commit and push if changed |
| 95 | + run: | |
| 96 | + git add _data/citations.yml |
| 97 | + git diff --staged --quiet || ( |
| 98 | + echo "📤 Committing and pushing changes..." |
| 99 | + git commit -m "Update Google Scholar citations" |
| 100 | + git push |
| 101 | + ) |
0 commit comments