-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (98 loc) · 3.92 KB
/
update-citations.yml
File metadata and controls
109 lines (98 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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@v5
# 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@v5
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
echo "success=true" >> $GITHUB_OUTPUT
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
echo "success=false" >> $GITHUB_OUTPUT
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
if: steps.run_citation_update.outputs.success == 'true'
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
if: steps.run_citation_update.outputs.success == 'true'
run: |
if [ -f _data/citations.yml ]; then
git add _data/citations.yml
git diff --staged --quiet || (
echo "📤 Committing and pushing changes..."
git commit -m "Update Google Scholar citations"
git push
)
else
echo "ℹ️ No citations.yml file to commit."
fi