pages/.github/workflows/update-citations.yml
Dominik Fuchß 1f349ffda2
Adapt mechanism for citiation count (#3177)
## Summary

This PR introduces an automated mechanism to update the citation count
for authors' publications.

- Inspired by @BernardoCama’s suggestion in #3150.
- Resolves #3150.

## Key Changes

- Adds an action to update publication citation counts.
    - Note: This action creates a commit on the main branch.
- To trigger further GitHub Actions workflows from this commit, a
Personal Access Token (PAT) must be used (the default GitHub Actions
token cannot trigger subsequent workflows).
- Adds and manages citation data in `_data/citations.yml`.
- Adds and adapts `bin/update_scholar_citations.py` to handle citation
updates.

## Usage Examples
### Timeout
<img width="758" height="415" alt="image"
src="https://github.com/user-attachments/assets/0a330d35-b386-4670-8668-62701f2dc68b"
/>

### Success

<img width="1684" height="857" alt="image"
src="https://github.com/user-attachments/assets/44aa0558-e02a-4f00-b8cb-9e0ce16dd53c"
/>
2025-11-16 22:17:17 -03:00

102 lines
3.6 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Update Google Scholar Citations
on:
schedule:
- cron: "0 0 * * 1" # Monday
- cron: "0 0 * * 3" # Wednesday
- cron: "0 0 * * 5" # Friday
workflow_dispatch:
jobs:
update-citations:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# See CUSTOMIZE.md for details on how to set up PAT for triggering subsequent workflows
# with:
# token: ${{ secrets.PAT }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.13"
- name: Install dependencies
run: |
echo "🔧 Installing dependencies..."
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Save current citations.yml hash
id: before
run: |
echo "📦 Checking existing citations.yml hash..."
if [ -f _data/citations.yml ]; then
sha_before=$(sha256sum _data/citations.yml | awk '{print $1}')
echo "sha_before=$sha_before" >> $GITHUB_OUTPUT
echo "📝 SHA before: $sha_before"
else
echo "sha_before=none" >> $GITHUB_OUTPUT
echo "📝 No existing citations.yml file found."
fi
- name: Run citation update script
id: run_citation_update
shell: bash
run: |
set +e
echo "🚀 Running citation update script (single attempt)..."
start_time=$(date)
timeout 90 python bin/update_scholar_citations.py
status=$?
end_time=$(date)
if [ $status -eq 0 ]; then
echo "✅ Citation update succeeded (started at $start_time, ended at $end_time)."
echo "✅ Citation update succeeded." >> $GITHUB_STEP_SUMMARY
else
echo "❌ Citation update script failed with exit code $status (started at $start_time, ended at $end_time)."
echo "❌ Citation update script failed with exit code $status." >> $GITHUB_STEP_SUMMARY
fi
set -e
- name: Save new citations.yml hash
id: after
run: |
echo "🔍 Checking updated citations.yml hash..."
if [ -f _data/citations.yml ]; then
sha_after=$(sha256sum _data/citations.yml | awk '{print $1}')
echo "sha_after=$sha_after" >> $GITHUB_OUTPUT
echo "📝 SHA after: $sha_after"
else
echo "sha_after=none" >> $GITHUB_OUTPUT
echo "📝 citations.yml was not created or is missing."
fi
- name: Report citations.yml change in summary
run: |
echo "📋 Comparing citation file hashes..."
if [ "${{ steps.before.outputs.sha_before }}" != "${{ steps.after.outputs.sha_after }}" ]; then
echo "✅ _data/citations.yml was updated."
echo "✅ _data/citations.yml was updated." >> $GITHUB_STEP_SUMMARY
else
echo " _data/citations.yml was not changed."
echo " _data/citations.yml was not changed." >> $GITHUB_STEP_SUMMARY
fi
- name: Configure Git
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
echo "🔧 Git configured."
- name: Commit and push if changed
run: |
git add _data/citations.yml
git diff --staged --quiet || (
echo "📤 Committing and pushing changes..."
git commit -m "Update Google Scholar citations"
git push
)